Skip to content

Commit

Permalink
Merge pull request #84 from ianwremmel/issue/79-in-src-dir
Browse files Browse the repository at this point in the history
fix(cli): only load typescript files if we can interpret typescript
  • Loading branch information
ianwremmel committed Apr 12, 2018
2 parents b7fd731 + 4ceb806 commit 5f67f43
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
20 changes: 4 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"precommit": "npm run --silent lint:staged",
"presemantic-release": "npm run build",
"semantic-release": "semantic-release",
"test": "jest --runInBand"
"test": "CLARK_ENV=development jest --runInBand"
},
"engines": {
"node": ">=8"
Expand Down Expand Up @@ -101,20 +101,8 @@
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFiles": [
"<rootDir>/test/initialize.ts"
],
"testMatch": [
"<rootDir>/src/**/*.spec.[tj]s?(x)",
"<rootDir>/test/*/spec/**/*.[tj]s?(x)"
]
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"setupFiles": ["<rootDir>/test/initialize.ts"],
"testMatch": ["<rootDir>/src/**/*.spec.[tj]s?(x)", "<rootDir>/test/*/spec/**/*.[tj]s?(x)"]
}
}
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const pkg = JSON.parse(readFileSync(pkgUp(__dirname), 'utf-8'));
// so, yargs's d.ts is...weird. This is an unfortunate set of castings to
// convince typescript that all is well.
const yargs = (y as any) as Argv;

yargs
// support ts extensions during development
.commandDir('./commands', {
extensions: __dirname.includes('src') ? ['js', 'ts'] : ['js'],
extensions: process.env.CLARK_ENV === 'development' ? ['js', 'ts'] : ['js'],
})
.options({
silent: {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/spec/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('exec', () => {

it('injects useful environment variables', async () => {
const result = await run(
'clark exec --silent --package @example/scoped-package-the-first "env | grep CLARK"',
'clark exec --silent --package @example/scoped-package-the-first "env | grep CLARK | grep -v CLARK_ENV"',
);
// strip out this project's path so we can write consistent assertions
const modified = result.replace(
Expand Down

0 comments on commit 5f67f43

Please sign in to comment.