1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const fs = require('fs');
|
11 | const path = require('path');
|
12 | const mkdirp = require('mkdirp');
|
13 |
|
14 | exports.command = 'init <path>';
|
15 |
|
16 | exports.description = 'create a client-side Mocha setup at <path>';
|
17 |
|
18 | exports.builder = yargs =>
|
19 | yargs.positional('path', {
|
20 | type: 'string',
|
21 | normalize: true
|
22 | });
|
23 |
|
24 | exports.handler = argv => {
|
25 | const destdir = argv.path;
|
26 | const srcdir = path.join(__dirname, '..', '..');
|
27 | mkdirp.sync(destdir);
|
28 | const css = fs.readFileSync(path.join(srcdir, 'mocha.css'));
|
29 | const js = fs.readFileSync(path.join(srcdir, 'mocha.js'));
|
30 | const tmpl = fs.readFileSync(
|
31 | path.join(srcdir, 'lib', 'browser', 'template.html')
|
32 | );
|
33 | fs.writeFileSync(path.join(destdir, 'mocha.css'), css);
|
34 | fs.writeFileSync(path.join(destdir, 'mocha.js'), js);
|
35 | fs.writeFileSync(path.join(destdir, 'tests.spec.js'), '');
|
36 | fs.writeFileSync(path.join(destdir, 'index.html'), tmpl);
|
37 | };
|