UNPKG

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