Skip to content

Commit

Permalink
CLI fix for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Oct 20, 2017
1 parent 53fa7a7 commit 7a8bc07
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ language: node_js
node_js:
- "8"
script:
- npm run prepublishOnly
- npm run checks
after_success:
- coveralls < coverage/lcov.info
8 changes: 4 additions & 4 deletions bin/yimp.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ const cleanPath = (x) => (x[0] === path.sep) ? x : path.join(process.cwd(), x);
return yargs.showHelp();
}

let ext;
let options = {};
if (argv.e) {
ext = argv.e.split(',').map(x => `.${x}`);
options.ext = argv.e.split(',').map(x => `.${x}`);
}

const input = cleanPath(argv.i);
if (!argv.o) {
process.stdout.write(yaml.dump(yimp.read(input)));
process.stdout.write(yaml.dump(yimp.read(input, options)));
return;
}

const output = cleanPath(argv.o);
yimp.write(input, output, { ext });
yimp.write(input, output, options);
})();
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function read(input, options = {}) {
}

function getSchema(dir, options = {}) {
if (!options.hasOwnProperty('ext')) {
if (!options.hasOwnProperty('ext')
|| !Array.isArray(options.ext)) {
options.ext = ['.yml', '.yaml'];
}
const dirFiles = (data) => {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"yimp": "bin/yimp.js"
},
"scripts": {
"lint": "eslint lib/*.js && eslint bin/*.js",
"lint:test": "eslint test/*.js",
"lint": "eslint lib/**/*.js && eslint bin/**/*.js",
"lint:test": "eslint test/**/*.js",
"lint:md": "markdownlint *.md --config markdown.json",
"test": "npm run lint:test && jest ./test/*.js --runInBand --runTestsByPath --verbose",
"test": "npm run lint:test && jest ./test/.*.test.js --runInBand --verbose",
"watch": "nodemon ./node_modules/.bin/run-s lint test",
"pre": "npm run prepublishOnly",
"prepublishOnly": "run-s lint lint:* && jest ./test/*.test.js --runTestsByPath",
"checks": "run-s lint lint:* && jest ./test/.*.test.js",
"prepublishOnly": "npm run checks",
"update:packages": "rm -rf node_modules && rm package-lock.json && npm update --save/save-dev && npm install && npm outdated"
},
"contributors": [
Expand Down
File renamed without changes.

0 comments on commit 7a8bc07

Please sign in to comment.