1 | #!/usr/bin/env node
|
2 | 'use strict'
|
3 |
|
4 |
|
5 | /* tslint:disable */
|
6 | // check if we're running in dev mode
|
7 | var devMode = require('fs').existsSync(`${__dirname}/../src`);
|
8 | // or want to "force" running the compiled version with --compiled-build
|
9 | var wantsCompiled = process.argv.indexOf('--compiled-build') >= 0;
|
10 |
|
11 | if (wantsCompiled || !devMode) {
|
12 | // this runs from the compiled javascript source
|
13 | var jscpd = require(`${__dirname}/../dist`);
|
14 | try {
|
15 | jscpd.jscpd(process.argv)
|
16 | .then(function() {
|
17 | process.exit(0)
|
18 | })
|
19 | .catch(function(e) {
|
20 | console.log(e);
|
21 | process.exit(1);
|
22 | });
|
23 | } catch (e) {
|
24 | console.log(e);
|
25 | process.exit(1);
|
26 | }
|
27 | } else {
|
28 | // this runs from the typescript source (for dev only)
|
29 | // hook into ts-node so we can run typescript on the fly
|
30 | require('ts-node').register({project: `${__dirname}/../tsconfig.json`});
|
31 | // run the CLI with the current process arguments
|
32 | var jscpd = require(`${__dirname}/../src`);
|
33 | try {
|
34 | jscpd.jscpd(process.argv)
|
35 | .then(function() {
|
36 | process.exit(0)
|
37 | })
|
38 | .catch(function(e) {
|
39 | console.log(e);
|
40 | process.exit(1);
|
41 | });
|
42 | } catch (e) {
|
43 | console.log(e);
|
44 | process.exit(1);
|
45 | }
|
46 | }
|