Skip to content
Myr

Enable TypeScript checking of javascript, and resolve or suppress errors (#1194)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 2491c76 · Browse files · 1 file+16 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−6 removed

  • other:+16 added−6 removed

1 file+16 added−6 removed

modified:index.js+16 added-6 removed
5 unmodified lines
6const spawn = require('child_process').spawn;7const path = require('path');8const fs = require('fs');910// @ts-check1112class Option {13 /**14 * Initialize a new `Option` with the given `flags` and `description`.15 *
7 unmodified lines
23 this.required = flags.indexOf('<') >= 0; // A value must be supplied when the option is specified.24 this.optional = flags.indexOf('[') >= 0; // A value is optional when the option is specified.25 this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line.26 this.negate = flags.indexOf('-no-') !== -1;25 flags = flags.split(/[ ,|]+/);26 if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();27 this.long = flags.shift();27 const flagParts = flags.split(/[ ,|]+/);28 if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) this.short = flagParts.shift();29 this.long = flagParts.shift();30 this.description = description || '';31 this.defaultValue = undefined;32 }3334 /**35 * Return option name.
49 unmodified lines
85 Error.captureStackTrace(this, this.constructor);86 this.name = this.constructor.name;87 this.code = code;88 this.exitCode = exitCode;89 this.nestedError = undefined;90 }91}9293class Command extends EventEmitter {
7 unmodified lines
101 constructor(name) {102 super();103 this.commands = [];104 this.options = [];105 this.parent = null;106 this._allowUnknownOption = false;107 this._args = [];108 this.rawArgs = null;109 this._scriptPath = null;
6 unmodified lines
116 this._executableHandler = false;117 this._executableFile = null; // custom name for executable118 this._defaultCommandName = null;119 this._exitCallback = null;120 this._alias = null;121122 this._noHelp = false;123 this._helpFlags = '-h, --help';124 this._helpDescription = 'display help for command';
514 unmodified lines
639 * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]640 *641 * @param {string[]} [argv] - optional, defaults to process.argv642 * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron637 * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'643 * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'644 * @return {Command} for chaining645 * @api public646 */647
5 unmodified lines
653654 // Default to using process.argv655 if (argv === undefined) {656 argv = process.argv;657 // @ts-ignore658 if (process.versions && process.versions.electron) {659 parseOptions.from = 'electron';660 }661 }
7 unmodified lines
669 this._scriptPath = argv[1];670 userArgs = argv.slice(2);671 break;672 case 'electron':673 // @ts-ignore674 if (process.defaultApp) {675 this._scriptPath = argv[1];676 userArgs = argv.slice(2);677 } else {
109 unmodified lines
787 }788789 const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];790 signals.forEach((signal) => {791 // @ts-ignore792 process.on(signal, () => {793 if (proc.killed === false && proc.exitCode === null) {794 proc.kill(signal);795 }
10 unmodified lines
806 exitCallback(new CommanderError(process.exitCode || 0, 'commander.executeSubCommandAsync', '(close)'));807 });808 }809 proc.on('error', (err) => {810 // @ts-ignore811 if (err.code === 'ENOENT') {812 const executableMissing = `'${bin}' does not exist813 - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead814 - if the default executable name is not suitable, use the executableFile option to supply a custom name`;815 throw new Error(executableMissing);816 // @ts-ignore817 } else if (err.code === 'EACCES') {818 throw new Error(`'${bin}' not executable`);819 }820 if (!exitCallback) {
308 unmodified lines
11291130 /**1131 * Unknown command.1132 *1122 * @param {string} flag1133 * @api private1134 */11351136 unknownCommand() {
17 unmodified lines
1154 *1155 * @param {string} str1156 * @param {string} [flags]1157 * @param {string} [description]1148 * @return {Command} for chaining1158 * @return {Command | string} this for chaining1159 * @api public1160 */11611162 version(str, flags, description) {
532 unmodified lines