Skip to content

Commit 9ddef90

Browse files
committed
Update CLI
1 parent 066dbbb commit 9ddef90

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

lib/node_modules/@stdlib/string/remove-first/bin/cli

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var join = require( 'path' ).join;
77
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
88
var CLI = require( '@stdlib/tools/cli' );
99
var stdin = require( '@stdlib/utils/read-stdin' );
10+
var RE_EOL = require( '@stdlib/regexp/eol' );
1011
var removeFirst = require( './../lib' );
1112

1213

@@ -22,11 +23,16 @@ var removeFirst = require( './../lib' );
2223
*/
2324
function onRead( error, data ) {
2425
/* eslint-disable no-console */
26+
var lines;
27+
var i;
2528
if ( error ) {
2629
process.exitCode = 1;
2730
return console.error( 'Error: %s', error.message );
2831
}
29-
console.log( removeFirst( data.toString() ) );
32+
lines = data.toString().split( RE_EOL );
33+
for ( i = 0; i < lines.length; i++ ) {
34+
console.log( removeFirst( lines[ i ] ) );
35+
}
3036
} // end FUNCTION onRead()
3137

3238

@@ -45,11 +51,12 @@ function main() {
4551
// Create a command-line interface:
4652
cli = new CLI({
4753
'pkg': require( './../package.json' ),
48-
'options': require( './opts.json' ),
49-
'help': readFileSync( join( __dirname, 'usage.txt' ), {
54+
'options': require( './../etc/cli_opts.json' ),
55+
'help': readFileSync( join( __dirname, '..', 'docs', 'usage.txt' ), {
5056
'encoding': 'utf8'
5157
})
5258
});
59+
5360
// Get any provided command-line arguments:
5461
args = cli.args();
5562

lib/node_modules/@stdlib/string/remove-first/test/test.cli.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tape( 'when invoked with a `--help` flag, the command-line interface prints the
3535
var expected;
3636
var cmd;
3737

38-
expected = readFileSync( resolve( __dirname, '..', 'bin', 'usage.txt' ), {
38+
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
3939
'encoding': 'utf8'
4040
});
4141
cmd = [
@@ -61,7 +61,7 @@ tape( 'when invoked with a `-h` flag, the command-line interface prints the help
6161
var expected;
6262
var cmd;
6363

64-
expected = readFileSync( resolve( __dirname, '..', 'bin', 'usage.txt' ), {
64+
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
6565
'encoding': 'utf8'
6666
});
6767
cmd = [
@@ -145,7 +145,7 @@ tape( 'the command-line interface removes the first character of a string argume
145145

146146
tape( 'the command-line interface supports use as a standard stream', opts, function test( t ) {
147147
var cmd = [
148-
'printf beep',
148+
'printf "beep\nboop"',
149149
'|',
150150
process.execPath,
151151
fpath
@@ -157,7 +157,7 @@ tape( 'the command-line interface supports use as a standard stream', opts, func
157157
if ( error ) {
158158
t.fail( error.message );
159159
} else {
160-
t.strictEqual( stdout.toString(), 'eep\n', 'expected value' );
160+
t.strictEqual( stdout.toString(), 'eep\noop\n', 'expected value' );
161161
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
162162
}
163163
t.end();

0 commit comments

Comments
 (0)