UNPKG

tsc-path-fix

Version:

Zero-runtime TypeScript path resolver - converts aliases to relative paths at compile time. Fast, lightweight, with native watch mode.

57 lines 3.03 kB
#! /usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const __1 = require(".."); const utils_1 = require("../utils"); const { version } = require('../../package.json'); commander_1.program .name('tsc-path-fix') .version(version) .option('-p, --project <file>', 'path to tsconfig.json') .option('-w, --watch', 'Observe file changes') .option('--outDir, --dir <dir>', 'Run in a folder leaving the "outDir" of the tsconfig.json (relative path to tsconfig)') .option('-f, --resolve-full-paths', 'Attempt to fully resolve import paths if the corresponding .js file can be found') .addOption(new commander_1.Option('-fe, --resolve-full-extension [ext]', 'Specify the extension of incomplete import paths, works with resolveFullPaths') .choices(['.js', '.mjs', '.cjs']) .default('.js')) .option('-s, --silent', 'Reduced terminal output (default: true) [deprecated]') .option('-v, --verbose', 'Additional information is send to the terminal') .option('--debug', 'Debug information is send to the terminal') .option('-r, --replacer <replacers...>', 'path to optional extra replacer') .option('--inputGlob <glob>', 'Overwrite glob used for file scanning') .option('--outputCheck <extensions...>', 'Overwrite file extensions used for path resolution') .option('--progress [boolean]', 'Show progress bar for long-running operations (default: true)', true) .parseAsync(process.argv); const options = commander_1.program.opts(); (() => __awaiter(void 0, void 0, void 0, function* () { yield (0, __1.replaceTscAliasPaths)({ resolveFullExtension: options.resolveFullExtension, configFile: options.project, watch: !!options.watch, outDir: options.dir, verbose: !!options.verbose, debug: !!options.debug, resolveFullPaths: !!options.resolveFullPaths, replacers: options.replacer, showProgress: options.progress !== 'false' && !!options.progress, fileExtensions: { inputGlob: options.inputGlob, outputCheck: options.outputCheck } }); (0, utils_1.notifyUpdates)(true, true); }))().catch(err => { console.error('Error:', err); process.exit(1); }); //# sourceMappingURL=index.js.map