Skip to content

Commit c355fe8

Browse files
committed
Move package, fix lint errors, and update CLI
1 parent 1054e61 commit c355fe8

File tree

21 files changed

+371
-131
lines changed

21 files changed

+371
-131
lines changed

tools/test-cov/tape-istanbul/README.md renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## Usage
88

99
```javascript
10-
var runner = require( '@stdlib/tools/test-cov/tape-istanbul' );
10+
var runner = require( '@stdlib/_tools/test-cov/tape-istanbul' );
1111
```
1212

1313
#### runner( pattern, \[options,] clbk )
@@ -53,7 +53,7 @@ runner( pattern, opts, done );
5353
<!-- eslint no-undef: "error" -->
5454

5555
```javascript
56-
var runner = require( '@stdlib/tools/test-cov/tape-istanbul' );
56+
var runner = require( '@stdlib/_tools/test-cov/tape-istanbul' );
5757

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

tools/test-cov/tape-istanbul/bin/usage.txt renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/docs/usage.txt

File renamed without changes.

tools/test-cov/tape-istanbul/bin/opts.json renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/etc/cli_opts.json

File renamed without changes.

tools/test-cov/tape-istanbul/examples/fixtures/foo.instrumented.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/examples/fixtures/foo.instrumented.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable */
12
"use strict";
23
var __cov_wwECwrz1fJkro0kbIuHk0A = (Function('return this'))();
34
if (!__cov_wwECwrz1fJkro0kbIuHk0A.__coverage__) { __cov_wwECwrz1fJkro0kbIuHk0A.__coverage__ = {}; }

tools/test-cov/tape-istanbul/examples/fixtures/foo.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/examples/fixtures/foo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable require-jsdoc */
12
'use strict';
23

34
function foo() {

tools/test-cov/tape-istanbul/examples/fixtures/test.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/examples/fixtures/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-restricted-syntax */
12
'use strict';
23

34
// MODULES //

tools/test-cov/tape-istanbul/examples/index.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/examples/index.js

File renamed without changes.

tools/test-cov/tape-istanbul/lib/compile.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/lib/compile.js

File renamed without changes.

tools/test-cov/tape-istanbul/lib/coverage.js renamed to lib/node_modules/@stdlib/_tools/test-cov/tape-istanbul/lib/coverage.js

File renamed without changes.

0 commit comments

Comments
 (0)