Skip to content

Commit 2dc65f7

Browse files
authored
Merge pull request #1 from hankei6km/csb-nm9b3
Fix crlf
2 parents 60f0d78 + 60baf9c commit 2dc65f7

File tree

4 files changed

+60
-48
lines changed

4 files changed

+60
-48
lines changed

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2021 hankei6km
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ typescript で npm 用の CLI とライブラリのパッケージを作成す
88

99
1. GitHub から import する(GitHubBox からは https://githubbox.com/hankei6km/my-starter-npm-cli-and-lib)
1010
1. fork
11-
1. `package.json``name` `version` `description` `license` あたりを新しいパッケージにあわせて変更。
11+
1. `package.json``name` `version` `description` `license` `LICENSE` あたりを新しいパッケージにあわせて変更。
1212
1. 新しい terminal を開き `$ npm run upgrade-interactive` 等でパッケージを更新。
1313

1414
これで 'npm run csb:test'(`jest --watchAll`) が terminal(「yarn start」タブ) 内で実行される。
@@ -35,4 +35,6 @@ typescript で npm 用の CLI とライブラリのパッケージを作成す
3535

3636
## ライセンス
3737

38-
[CC0 1.0](http://creativecommons.org/publicdomain/zero/1.0/deed.ja)
38+
MIT License
39+
40+
Copyright (c) 2021 hankei6km

src/cli.test.ts

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import { PassThrough } from 'stream';
2-
import cli from './cli';
3-
4-
describe('cli()', () => {
5-
it('should return stdout with exitcode=0', async () => {
6-
const stdout = new PassThrough();
7-
const stderr = new PassThrough();
8-
const outData = jest.fn();
9-
stdout.on('data', outData);
10-
const errData = jest.fn();
11-
stderr.on('data', errData);
12-
expect(
13-
await cli({
14-
filename: 'test/assets/test.txt',
15-
stdout,
16-
stderr
17-
})
18-
).toEqual(0);
19-
expect(outData.mock.calls.length).toEqual(1);
20-
expect(outData.mock.calls[0][0].toString('utf8')).toEqual(
21-
'test/assets/test.txt: 15 chars\n'
22-
);
23-
expect(errData.mock.calls.length).toEqual(0);
24-
});
25-
it('should return stderr with exitcode=1', async () => {
26-
const stdout = new PassThrough();
27-
const stderr = new PassThrough();
28-
const outData = jest.fn();
29-
stdout.on('data', outData);
30-
const errData = jest.fn();
31-
stderr.on('data', errData);
32-
expect(
33-
await cli({
34-
filename: 'test/assets/fail.txt',
35-
stdout,
36-
stderr
37-
})
38-
).toEqual(1);
39-
expect(outData.mock.calls.length).toEqual(0);
40-
expect(errData.mock.calls.length).toEqual(2);
41-
expect(errData.mock.calls[0][0].toString('utf8')).toEqual(
42-
"Error: ENOENT: no such file or directory, open 'test/assets/fail.txt'"
43-
);
44-
expect(errData.mock.calls[1][0].toString('utf8')).toEqual('\n');
45-
});
46-
});
1+
import { PassThrough } from 'stream';
2+
import cli from './cli';
3+
4+
describe('cli()', () => {
5+
it('should return stdout with exitcode=0', async () => {
6+
const stdout = new PassThrough();
7+
const stderr = new PassThrough();
8+
const outData = jest.fn();
9+
stdout.on('data', outData);
10+
const errData = jest.fn();
11+
stderr.on('data', errData);
12+
expect(
13+
await cli({
14+
filename: 'test/assets/test.txt',
15+
stdout,
16+
stderr
17+
})
18+
).toEqual(0);
19+
expect(outData.mock.calls.length).toEqual(1);
20+
expect(outData.mock.calls[0][0].toString('utf8')).toEqual(
21+
'test/assets/test.txt: 15 chars\n'
22+
);
23+
expect(errData.mock.calls.length).toEqual(0);
24+
});
25+
it('should return stderr with exitcode=1', async () => {
26+
const stdout = new PassThrough();
27+
const stderr = new PassThrough();
28+
const outData = jest.fn();
29+
stdout.on('data', outData);
30+
const errData = jest.fn();
31+
stderr.on('data', errData);
32+
expect(
33+
await cli({
34+
filename: 'test/assets/fail.txt',
35+
stdout,
36+
stderr
37+
})
38+
).toEqual(1);
39+
expect(outData.mock.calls.length).toEqual(0);
40+
expect(errData.mock.calls.length).toEqual(2);
41+
expect(errData.mock.calls[0][0].toString('utf8')).toEqual(
42+
"Error: ENOENT: no such file or directory, open 'test/assets/fail.txt'"
43+
);
44+
expect(errData.mock.calls[1][0].toString('utf8')).toEqual('\n');
45+
});
46+
});

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env node
12
import yargs from 'yargs';
23
import { hideBin } from 'yargs/helpers';
34
import cli from './cli';

0 commit comments

Comments
 (0)