From 7b4792b7b01b2186f62c72c0654d0388a76f850e Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 29 Nov 2016 09:43:14 -0800 Subject: [PATCH] Run linter with the package as its cwd (#12966) --- scripts/lint.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/lint.js b/scripts/lint.js index 1ae8e24d40..f54df63d65 100644 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -2,16 +2,17 @@ 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" -const tslintPath = existsSync(symlinkedTslintPath) ? symlinkedTslintPath : "node_modules/tslint"; -const cmd = `node ${tslintPath}/lib/tslint-cli --format stylish ${pkg}/**/*.d.ts`; +const symlinkedTslintPath = "../node_modules/types-publisher/node_modules/tslint" +const tslintPath = existsSync(path.join(pkg, symlinkedTslintPath)) ? symlinkedTslintPath : "../node_modules/tslint"; +const cmd = `node ${tslintPath}/lib/tslint-cli --format stylish **/*.d.ts`; console.log(cmd); try { // Child process writes directly to our own stdout - execSync(cmd, { stdio: "inherit" }); + execSync(cmd, { cwd: pkg, stdio: "inherit" }); } catch (_) { // Process should have printed out error info }