Skip to content

Commit 9be9e95

Browse files
committed
Update snippet
1 parent 77e96c9 commit 9be9e95

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tools/snippets/test/test.cli.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ var opts = {
2020
// FIXTURES //
2121

2222
var PKG_VERSION = require('./../package.json' ).version;
23-
var HELP = readFileSync( resolve( __dirname, '..', 'bin', 'usage.txt' ), {
24-
'encoding': 'utf8'
25-
});
2623

2724

2825
// TESTS //
@@ -33,7 +30,13 @@ tape( 'command-line interface', function test( t ) {
3330
});
3431

3532
tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
36-
var cmd = [
33+
var expected;
34+
var cmd;
35+
36+
expected = readFileSync( resolve( __dirname, '..', 'bin', 'usage.txt' ), {
37+
'encoding': 'utf8'
38+
});
39+
cmd = [
3740
process.execPath,
3841
fpath,
3942
'--help'
@@ -46,14 +49,20 @@ tape( 'when invoked with a `--help` flag, the command-line interface prints the
4649
t.fail( error.message );
4750
} else {
4851
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
49-
t.strictEqual( stderr.toString(), HELP+'\n', 'expected value' );
52+
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
5053
}
5154
t.end();
5255
}
5356
});
5457

5558
tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
56-
var cmd = [
59+
var expected;
60+
var cmd;
61+
62+
expected = readFileSync( resolve( __dirname, '..', 'bin', 'usage.txt' ), {
63+
'encoding': 'utf8'
64+
});
65+
cmd = [
5766
process.execPath,
5867
fpath,
5968
'-h'
@@ -66,7 +75,7 @@ tape( 'when invoked with a `-h` flag, the command-line interface prints the help
6675
t.fail( error.message );
6776
} else {
6877
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
69-
t.strictEqual( stderr.toString(), HELP+'\n', 'expected value' );
78+
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
7079
}
7180
t.end();
7281
}

0 commit comments

Comments
 (0)