Skip to content

Commit

Permalink
requirement down
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed May 20, 2018
1 parent a2e3f2c commit 0dc49e0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

requirement: Node 10 => Node 8

## 1.0.0

:tada:
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

![hosejs](https://github.com/deptno/hosejs/raw/master/asset/hosejs.gif)

> Required node > v10
Transform JSON data with just **JavaScript** in terminal

`jq`? javascript is clearly better option for people already use javascript.
Expand All @@ -27,7 +25,7 @@ npm -g install hosejs

## usage

```
```bash
$ cat some.json | j '_.map(x => x.timestamp)'
$ cat some.json | j '_.map(x => x.timestamp)' --tab 4
$ cat some.json | j '_.map(x => x.timestamp)' --file pre.js --tab 2
Expand Down
12 changes: 2 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

import {chomp, chunksToLinesAsync} from '@rauschma/stringio'
import {createContext, runInContext} from 'vm'
import * as meow from 'meow'
import * as fs from 'fs'
import {promisify} from 'util'
import * as stdin from 'get-stdin'

const program = meow(`
HoseJS
Expand All @@ -29,24 +29,16 @@ const program = meow(`
async function main() {
const {input, flags} = program
const readFile = promisify(fs.readFile)
const stream = process.stdin as any
const lines = []

if (flags.file) {
input.unshift((await readFile(flags.file)).toString())
}

for await (const line of chunksToLinesAsync(stream)) {
lines.push(chomp(line))
}

try {
const _ = JSON.parse(lines.join(''))
const _ = JSON.parse(await stdin())
const sandbox = {_}

createContext(sandbox)
runInContext(input.map(c => `_ = ${c}`).join(';'), sandbox)

print(sandbox._, parseInt(flags.tab))
} catch (e) {
console.error('🚫', e)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hosejs",
"version": "1.0.0",
"version": "1.1.0",
"description": "javascript pipe, jq alternative",
"main": "index.js",
"bin": {
Expand All @@ -14,7 +14,7 @@
"author": "Bonggyun Lee <deptno@gmail.com>",
"license": "MIT",
"dependencies": {
"@rauschma/stringio": "^1.4.0",
"get-stdin": "^6.0.0",
"meow": "^5.0.0"
},
"devDependencies": {
Expand Down
16 changes: 5 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# yarn lockfile v1


"@rauschma/stringio@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@rauschma/stringio/-/stringio-1.4.0.tgz#0b667bea726652a10a48dfc1dadc89e0ec51e269"
dependencies:
"@types/node" "^10.0.3"

"@types/meow@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/meow/-/meow-4.0.1.tgz#cb80b9f0b8695df7ac15f0165585bcd2d0a6d94f"
Expand All @@ -24,14 +18,10 @@
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"

"@types/node@^10.0.3", "@types/node@^10.1.0":
"@types/node@^10.1.0":
version "10.1.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.2.tgz#1b928a0baa408fc8ae3ac012cc81375addc147c6"

"@types/ramda@^0.25.28":
version "0.25.29"
resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.25.29.tgz#05a58a3ba728344ecc9d99e37beb2adf822fb01c"

array-find-index@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
Expand Down Expand Up @@ -85,6 +75,10 @@ find-up@^2.0.0:
dependencies:
locate-path "^2.0.0"

get-stdin@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"

graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
Expand Down

0 comments on commit 0dc49e0

Please sign in to comment.