-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d1e018
commit f825dc5
Showing
9 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,5 @@ | |
} | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"globby": "^8.0.1", | ||
"ts-node": "^6.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "single-cmd-cli", | ||
"version": "0.0.0", | ||
"description": "Single Command CLI", | ||
"private": true, | ||
"oclif": { | ||
"default": ".", | ||
"commands": "./dist" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint-disable-next-line node/no-unpublished-import | ||
import {Command} from '../../../../../src/index' | ||
|
||
export default class FooBar extends Command { | ||
public static description = 'Description of single command CLI.' | ||
public async run(): Promise<void> { | ||
this.log('hello world!') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDirs": ["./src"] | ||
}, | ||
"include": ["./src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,5 @@ | |
} | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"globby": "^8.0.1", | ||
"ts-node": "^6.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {expect} from 'chai' | ||
import {resolve} from 'node:path' | ||
import {SinonSandbox, SinonStub, createSandbox} from 'sinon' | ||
import stripAnsi from 'strip-ansi' | ||
|
||
import {run, ux} from '../../src/index' | ||
|
||
describe('single command cli', () => { | ||
let sandbox: SinonSandbox | ||
let stdoutStub: SinonStub | ||
|
||
beforeEach(() => { | ||
sandbox = createSandbox() | ||
stdoutStub = sandbox.stub(ux.write, 'stdout') | ||
}) | ||
|
||
afterEach(() => { | ||
sandbox.restore() | ||
}) | ||
|
||
it('should show help for commands', async () => { | ||
await run(['--help'], resolve(__dirname, 'fixtures/single-cmd-cli/package.json')) | ||
expect(stdoutStub.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`Description of single command CLI. | ||
USAGE | ||
$ single-cmd-cli . | ||
DESCRIPTION | ||
Description of single command CLI. | ||
`) | ||
}) | ||
|
||
it('should run command', async () => { | ||
await run([], resolve(__dirname, 'fixtures/single-cmd-cli/package.json')) | ||
expect(stdoutStub.firstCall.firstArg).to.equal('hello world!\n') | ||
}) | ||
}) |