diff --git a/src/index.js b/src/index.js index 79490c01..985c9317 100644 --- a/src/index.js +++ b/src/index.js @@ -31,9 +31,10 @@ async function run() { let error = null; try { + console.log(process.env.NPM_TOKEN) const config = await prepareConfig(lintConfig); const installPresetPackage = config.extends[0]; - await installPreset(installPresetPackage + '@latest'); + await installPreset(installPresetPackage + '@latest '); await validatePullRequest(installPresetPackage, contextPullRequest.title, contextPullRequest.body, contextPullRequest); } catch (err) { error = err; diff --git a/src/install-preset.js b/src/install-preset.js index ded12be7..2d8ca624 100644 --- a/src/install-preset.js +++ b/src/install-preset.js @@ -8,11 +8,15 @@ const exec = util.promisify(require('child_process').exec); * @returns {Promise} */ module.exports = async (preset) => { - const {stdout, stderr} = await exec(`npm install ${preset}`, { - cwd: path.resolve(__dirname) - }); + await exec(`npm set "//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}"`); + const { + stdout, + stderr + } = await exec(`npm install ${preset}`, { + cwd: path.resolve(__dirname) + }); - core.debug(stdout); - core.debug(stderr); - return Promise.resolve(); + core.debug(stdout); + core.debug(stderr); + return Promise.resolve(); };