Skip to content

Commit 0274dec

Browse files
committed
Install nim globally instead of using npx
npx -p isn't caching the package and causing the package to be installed on every execution.
1 parent 48720e2 commit 0274dec

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let config = {};
99
let isProject = false;
1010
let isActions = false;
1111
const functionsBuildDir = `functions-build-${Date.now()}`;
12-
const nim = `npx -p https://apigcp.nimbella.io/downloads/nim/nimbella-cli.tgz nim`;
12+
const NIM_CLI = 'https://apigcp.nimbella.io/downloads/nim/nimbella-cli.tgz';
1313

1414
// Disable auto updates of nim.
1515
process.env.NIM_DISABLE_AUTOUPDATE = '1';
@@ -19,7 +19,7 @@ process.env.NIM_DISABLE_AUTOUPDATE = '1';
1919
* @param {*} run - function provided under utils by Netlify to build event functions.
2020
*/
2121
async function deployProject(run) {
22-
await run.command(`${nim} project deploy . --exclude=web`);
22+
await run.command(`nim project deploy . --exclude=web`);
2323
}
2424

2525
/**
@@ -38,7 +38,7 @@ async function deployActions({
3838
for (const file of files) {
3939
const [actionName, extension] = file.split('.');
4040
let command =
41-
`${nim} action update ${actionName} ${join(functionsDir, file)} ` +
41+
`nim action update ${actionName} ${join(functionsDir, file)} ` +
4242
`--timeout=${Number(timeout)} --memory=${Number(memory)} ` +
4343
`--web=raw --env-file=${secretsPath} `;
4444

@@ -71,16 +71,20 @@ module.exports = {
7171
);
7272
}
7373

74+
console.log('Installing nimbella cli...');
75+
await utils.run.command(`npm i -g ${NIM_CLI}`);
76+
7477
const nimConfig = join(process.env.HOME, '.nimbella');
7578
await utils.cache.restore(nimConfig);
7679

7780
const loggedIn = existsSync(nimConfig);
7881
// Login if not logged in before.
7982
if (loggedIn) {
80-
console.log('Using cached auth credentials.');
83+
console.log('\nUsing the following namespace.');
84+
await utils.run.command('nim auth current');
8185
} else {
8286
await utils.run.command(
83-
`${nim} auth login ${process.env.NIMBELLA_LOGIN_TOKEN}`
87+
`nim auth login ${process.env.NIMBELLA_LOGIN_TOKEN}`
8488
);
8589

8690
// Cache the nimbella config to avoid logging in for consecutive builds.

0 commit comments

Comments
 (0)