Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for node 6 #67

Merged
merged 4 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
["env", {
"targets": {
"node": "6"
}
}],
"stage-2"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
dist
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
language: node_js
script:
- npm run build
- npm test
node_js:
- 8
- "8"
- "6"
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports =
parseInt(process.versions.node, 10) < 8
? require('./dist/index.js')
: require('./lib/index.js');
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
"description": "Lightweight, beautiful and user-friendly prompts",
"homepage": "https://github.com/terkelg/prompts",
"repository": "terkelg/prompts",
"main": "lib/index.js",
"main": "index.js",
"author": {
"name": "Terkel Gjervig",
"email": "terkel@terkel.com",
"url": "https://terkel.com"
},
"files": [
"lib"
"lib",
"dist",
"index.js"
],
"scripts": {
"start": "node lib/index.js",
"build": "babel lib -d dist",
"test": "tape test/*.js | tap-spec"
},
"keywords": [
Expand All @@ -31,10 +34,13 @@
"sisteransi": "^0.1.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"tap-spec": "^4.1.1",
"tape": "^4.8.0"
},
"engines": {
"node": ">= 8"
"node": ">= 6"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
$ npm install --save prompts
```

> This package uses async/await and requires Node.js 7.6
> This package supports Node 6 and above

![split](https://github.com/terkelg/prompts/raw/master/media/split.png)

Expand Down
25 changes: 14 additions & 11 deletions test/prompts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const test = require('tape');
const prompt = require('../lib');
const prompt = require('../');
const { prompts } = prompt;

test('basics', t => {
Expand Down Expand Up @@ -36,18 +36,21 @@ test('prompts', t => {
t.equal(Object.keys(prompts).length, types.length, 'all prompts are exported');
});

test('injects', async t => {
test('injects', t => {
let obj = { a:1, b:2, c:3 };
prompt.inject(obj);
t.same(prompt._map, obj, 'injects key:val object of answers');

let foo = await prompt({ name:'a' });
t.same(foo, { a:1 }, 'immediately returns object with injected answer');
t.same(prompt._map, { b:2, c:3 }, 'deletes the `a` key from internal map');

let bar = await prompt([{ name:'b' }, { name:'c' }]);
t.same(bar, { b:2, c:3 }, 'immediately handles two prompts at once');
t.same(prompt._map, {}, 'leaves behind empty internal mapping when exhausted');

t.end();
prompt({ name:'a' })
.then(foo => {
t.same(foo, { a:1 }, 'immediately returns object with injected answer');
t.same(prompt._map, { b:2, c:3 }, 'deletes the `a` key from internal map');

prompt([{ name:'b' }, { name:'c' }])
.then(bar => {
t.same(bar, { b:2, c:3 }, 'immediately handles two prompts at once');
t.same(prompt._map, {}, 'leaves behind empty internal mapping when exhausted');
t.end();
})
})
})