DefinitelyTyped/scripts/lint.js
Andy 2f71174636 Restructure to support old versions (#13811)
* Restructure to support old versions

* Fix tests
2017-01-06 12:36:57 -08:00

26 lines
942 B
JavaScript

// Usage: npm run lint -- my-package-name
const pkg = process.argv[2];
const execSync = require("child_process").execSync;
const existsSync = require("fs").existsSync;
const path = require("path");
// Path of tslint when `types-publisher` is symlinked
const symlinkedTslintPath = "../node_modules/types-publisher/node_modules/tslint"
let tslintPath = existsSync(path.join(pkg, symlinkedTslintPath)) ? symlinkedTslintPath : "../node_modules/tslint";
// An older version (e.g. abs/v0) is in a nested directory, so needs to look one more level up for tslint.
if (pkg.includes("/")) {
tslintPath = path.join("..", tslintPath);
}
const cmd = `node ${tslintPath}/lib/tslint-cli --format stylish "**/*.d.ts"`;
console.log(cmd);
console.log(pkg);
process.exit(0);
try {
// Child process writes directly to our own stdout
execSync(cmd, { cwd: pkg, stdio: "inherit" });
} catch (_) {
// Process should have printed out error info
}