add support for execute typescript subcommand via ts-node
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by KillWolfVlad · committed by KillWolfVlad · parent e5b27cc · Browse files · 6 files·+79 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+79 added−2 removed
- tests:+21 added−0 removed
- other:+58 added−2 removed
Provenance
- Commit
bf47dcc- Tree
1c8e904- Author
KillWolfVlad <KillWolfVlad@users.noreply.github.com>- Committer
KillWolfVlad <KillWolfVlad@users.noreply.github.com>- Parent
e5b27cc
6 files changed+79 added−2 removed
added:test/fixtures-ts/pm-install.ts+3 added
123#!/usr/bin/env node
console.log('install');added:test/fixtures-ts/pm.ts+8 added
12345678#!/usr/bin/env node
var program = require('../../');
program .version('0.0.1') .command('install [name]', 'install one or more packages') .parse(process.argv);added:test/test.command.executableSubcommand.tsnode.js+10 added
12345678910var exec = require('child_process').exec , path = require('path') , should = require('should');
var bin = path.join(__dirname, './fixtures-ts/pm.ts')
// success caseexec(process.argv[0] + ' -r ts-node/register ' + bin + ' install', function (error, stdout, stderr) { stdout.should.equal('install\n');});modified:index.js+5 added-2 removed
521 unmodified lines522 523 // executable524 var f = argv[1];525 // name of the subcommand, link `pm-install`526- var bin = basename(f, '.js') + '-' + args[0];526+ var bin = basename(f, path.extname(f)) + '-' + args[0];527 528 // In case of globally installed, get the base dir where executable529 // subcommand file should be located at530 var baseDir,7 unmodified lines538 539 // prefer local `./<bin>` to bin in the $PATH540 var localBin = path.join(baseDir, bin);541 542- // whether bin file is a js script with explicit `.js` extension542+ // whether bin file is a js script with explicit `.js` or `.ts` extension543 var isExplicitJS = false;544 if (exists(localBin + '.js')) {545 bin = localBin + '.js';546 isExplicitJS = true;547+ } else if (exists(localBin + '.ts')) {548+ bin = localBin + '.ts';549+ isExplicitJS = true;550 } else if (exists(localBin)) {551 bin = localBin;552 }553 686 unmodified linesmodified:package-lock.json+52 added
1148 unmodified lines1149 "pseudomap": "^1.0.2",1150 "yallist": "^2.1.2"1151 }1152 },1153+ "make-error": {1154+ "version": "1.3.4",1155+ "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",1156+ "integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==",1157+ "dev": true1158+ },1159 "mimic-fn": {1160 "version": "1.2.0",1161 "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",1162 "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",629 unmodified lines1792 "requires": {1793 "is-fullwidth-code-point": "^2.0.0"1794 }1795 },1796+ "source-map": {1797+ "version": "0.6.1",1798+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",1799+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",1800+ "dev": true1801+ },1802+ "source-map-support": {1803+ "version": "0.5.8",1804+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz",1805+ "integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==",1806+ "dev": true,1807+ "requires": {1808+ "buffer-from": "^1.0.0",1809+ "source-map": "^0.6.0"1810+ }1811+ },1812 "spdx-correct": {1813 "version": "3.0.0",1814 "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz",1815 "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==",342 unmodified lines2158 "requires": {2159 "os-tmpdir": "~1.0.2"2160 }2161 },2162+ "ts-node": {2163+ "version": "7.0.1",2164+ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",2165+ "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==",2166+ "dev": true,2167+ "requires": {2168+ "arrify": "^1.0.0",2169+ "buffer-from": "^1.1.0",2170+ "diff": "^3.1.0",2171+ "make-error": "^1.1.1",2172+ "minimist": "^1.2.0",2173+ "mkdirp": "^0.5.1",2174+ "source-map-support": "^0.5.6",2175+ "yn": "^2.0.0"2176+ },2177+ "dependencies": {2178+ "minimist": {2179+ "version": "1.2.0",2180+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",2181+ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",2182+ "dev": true2183+ }2184+ }2185+ },2186 "type-check": {2187 "version": "0.3.2",2188 "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",2189 "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",91 unmodified lines2281 "version": "2.1.2",2282 "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",2283 "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",2284 "dev": true2285+ },2286+ "yn": {2287+ "version": "2.0.0",2288+ "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",2289+ "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=",2290+ "dev": true2291 }2292 }2293 }modified:package.json+1 added
29 unmodified lines30313233343536373829 unmodified lines "eslint": "^5.3.0", "should": "^13.2.3", "sinon": "^6.1.4", "standard": "^11.0.1", "ts-node": "^7.0.1", "typescript": "^2.9.2" }, "typings": "typings/index.d.ts"}