Move package, update CLI, and add tests · stdlib-js/stdlib@03e6b44 · GitHub
Skip to content

Commit 03e6b44

Browse files
committed
Move package, update CLI, and add tests
1 parent d8bee1d commit 03e6b44

15 files changed

Lines changed: 445 additions & 136 deletions

File tree

tools/benchmarks/browser-build/README.md renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/README.md

Lines changed: 2 additions & 2 deletions
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
// MODULES //
5+
6+
var cwd = require( '@stdlib/process/cwd' );
7+
var join = require( 'path' ).join;
8+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
9+
var CLI = require( '@stdlib/tools/cli' );
10+
var build = require( './../lib' );
11+
12+
13+
// FUNCTIONS //
14+
15+
/**
16+
* Callback invoked upon completion.
17+
*
18+
* @private
19+
* @param {(Error|null)} error - error object
20+
*/
21+
function onFinish( error ) {
22+
if ( error ) {
23+
throw error;
24+
}
25+
}
26+
27+
28+
// MAIN //
29+
30+
/**
31+
* Main execution sequence.
32+
*
33+
* @private
34+
* @returns {void}
35+
*/
36+
function main() {
37+
var flags;
38+
var opts;
39+
var args;
40+
var root;
41+
var cli;
42+
var out;
43+
44+
// Create a command-line interface:
45+
cli = new CLI({
46+
'pkg': require( './../package.json' ),
47+
'options': require( './../etc/cli_opts.json' ),
48+
'help': readFileSync( join( __dirname, '..', 'docs', 'usage.txt' ), {
49+
'encoding': 'utf8'
50+
})
51+
});
52+
53+
// Get any provided command-line arguments:
54+
args = cli.args();
55+
56+
// Get any provided command-line options:
57+
flags = cli.flags();
58+
59+
opts = {};
60+
if ( flags.pattern ) {
61+
opts.pattern = flags.pattern;
62+
}
63+
if ( flags.bundle ) {
64+
opts.bundle = flags.bundle;
65+
}
66+
if ( flags.html ) {
67+
opts.html = flags.html;
68+
}
69+
if ( flags.mount ) {
70+
opts.mount = flags.mount;
71+
}
72+
if ( flags.title ) {
73+
opts.title = flags.title;
74+
}
75+
if ( flags.out ) {
76+
out = flags.out;
77+
} else {
78+
out = cwd();
79+
}
80+
if ( args[ 0 ] ) {
81+
root = args[ 0 ];
82+
} else {
83+
root = cwd();
84+
}
85+
build( root, out, opts, onFinish );
86+
}
87+
88+
main();

tools/benchmarks/browser-build/bin/usage.txt renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/docs/usage.txt

File renamed without changes.

tools/benchmarks/browser-build/bin/opts.json renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/etc/cli_opts.json

File renamed without changes.

tools/benchmarks/browser-build/examples/fixtures/index.js renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/examples/fixtures/index.js

File renamed without changes.

tools/benchmarks/browser-build/examples/index.js renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/examples/index.js

File renamed without changes.

tools/benchmarks/browser-build/lib/build.js renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/lib/build.js

File renamed without changes.

tools/benchmarks/browser-build/lib/defaults.json renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/lib/defaults.json

File renamed without changes.

tools/benchmarks/browser-build/lib/index.js renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/lib/index.js

Lines changed: 2 additions & 2 deletions

tools/benchmarks/browser-build/lib/validate.js renamed to lib/node_modules/@stdlib/_tools/benchmarks/browser-build/lib/validate.js

File renamed without changes.

0 commit comments

Comments
 (0)