Skip to content

Commit

Permalink
feat(CLI): Supporting config files and package.json section
Browse files Browse the repository at this point in the history
fix #4
  • Loading branch information
Igmat committed Jan 22, 2018
1 parent e0ea1b9 commit 3eb8017
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 29 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"postinstall": "lerna bootstrap",
"build": "lerna run build",
"watch": "lerna run watch --parallel",
"test": "lerna link && node ./packages/baset/bin/index.js -s tests/*.spec.js",
"accept": "node ./packages/baset/bin/index.js a -b tests/*.base",
"test": "lerna link && node ./packages/baset/bin/index.js",
"accept": "node ./packages/baset/bin/index.js a",
"doctoc": "doctoc README.md CONTRIBUTING.md",
"commit": "git-cz"
},
Expand All @@ -28,5 +28,9 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"baset": {
"specs": "tests/*.spec.js",
"bases": "tests/*.base"
}
}
56 changes: 29 additions & 27 deletions packages/baset-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"name": "baset-cli",
"version": "0.2.2",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "npm run tslint && tsc",
"watch": "npm run tslint && tsc -w",
"tslint": "tslint -c tslint.json -p tsconfig.json",
"test": "baset"
},
"author": "",
"license": "MIT",
"devDependencies": {
"@types/glob": "^5.0.34",
"@types/node": "^9.3.0",
"@types/yargs": "^10.0.1",
"baset": "^0.2.2",
"tslint": "^5.9.1",
"typescript": "^2.6.2"
},
"dependencies": {
"baset-core": "^0.2.2",
"glob": "^7.1.2",
"glob-promise": "^3.3.0",
"yargs": "^10.1.1"
}
"name": "baset-cli",
"version": "0.2.2",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "npm run tslint && tsc",
"watch": "npm run tslint && tsc -w",
"tslint": "tslint -c tslint.json -p tsconfig.json",
"test": "baset"
},
"author": "",
"license": "MIT",
"devDependencies": {
"@types/find-up": "^2.1.1",
"@types/glob": "^5.0.34",
"@types/node": "^9.3.0",
"@types/yargs": "^10.0.1",
"baset": "^0.2.2",
"tslint": "^5.9.1",
"typescript": "^2.6.2"
},
"dependencies": {
"baset-core": "^0.2.2",
"find-up": "^2.1.0",
"glob": "^7.1.2",
"glob-promise": "^3.3.0",
"yargs": "^10.1.1"
}
}
6 changes: 6 additions & 0 deletions packages/baset-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { sync } from 'find-up';
import * as fs from 'fs';
import * as yargs from 'yargs';
const configPath = sync(['.basetrc', '.basetrc.json']);
const config = configPath ? JSON.parse(fs.readFileSync(configPath, { encoding: 'utf8' })) : {};

export const cli = yargs
.usage('$0 <command>')
.commandDir('./commands')
.pkgConf('baset')
.config(config)
.help('h')
.alias('help', 'h')
.epilog('Made by Igmat.');
4 changes: 4 additions & 0 deletions tests/sample-project/.basetrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"specs": "**/*.spec.js",
"bases": "**/*.base"
}

0 comments on commit 3eb8017

Please sign in to comment.