Last active
June 22, 2024 14:34
Revisions
-
ArtemAvramenko revised this gist
Jul 17, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const readLockFile = path => { const text = fs.readFileSync(path, { encoding:'utf8', flag:'r' }); const lockFile = JSON.parse(text); delete lockFile.dependencies; delete lockFile.lockfileVersion; Object.getOwnPropertyNames(lockFile.packages).forEach(p => { if (p === '' || lockFile.packages[p].optional) { delete lockFile.packages[p]; -
ArtemAvramenko revised this gist
Jan 5, 2023 . No changes.There are no files selected for viewing
-
ArtemAvramenko revised this gist
Sep 2, 2022 . 1 changed file with 1 addition and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,8 @@ // Fastest install script for npm 7.0+ // usage: node install const fs = require('fs'); const readLockFile = path => { if (fs.existsSync(path)) { const text = fs.readFileSync(path, { encoding:'utf8', flag:'r' }); @@ -22,26 +20,10 @@ const readLockFile = path => { const expected = readLockFile('./package-lock.json'); // call npm ci only when package-lock changed if (expected) { const actual = readLockFile('./node_modules/.package-lock.json'); if (!actual || JSON.stringify(actual) !== JSON.stringify(expected)) { const { execSync } = require('child_process'); execSync('npm ci', { stdio: 'inherit' }); } } -
ArtemAvramenko revised this gist
Sep 15, 2021 . 1 changed file with 17 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,17 +5,27 @@ const fs = require('fs'); const minNodeVer = 14; const minNpmVer = 7; const readLockFile = path => { if (fs.existsSync(path)) { const text = fs.readFileSync(path, { encoding:'utf8', flag:'r' }); const lockFile = JSON.parse(text); delete lockFile.dependencies; Object.getOwnPropertyNames(lockFile.packages).forEach(p => { if (p === '' || lockFile.packages[p].optional) { delete lockFile.packages[p]; } }); return lockFile; } } const expected = readLockFile('./package-lock.json'); // call npm ci only when package-lock changed if (expected) { const actual = readLockFile('./node_modules/.package-lock.json'); if (!actual || JSON.stringify(actual) !== JSON.stringify(expected)) { -
ArtemAvramenko created this gist
Sep 13, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ // usage: node install const fs = require('fs'); const minNodeVer = 14; const minNpmVer = 7; const readJSON = path => fs.existsSync(path) && JSON.parse(fs.readFileSync(path), { encoding:'utf8', flag:'r' }); const expected = readJSON('./package-lock.json'); if (expected) { delete expected.packages['']; delete expected.dependencies; const actual = readJSON('./node_modules/.package-lock.json'); if (!actual || JSON.stringify(actual) !== JSON.stringify(expected)) { const { execSync } = require('child_process'); const nodeVer = process.versions.node; if (+nodeVer.split('.')[0] < minNodeVer) { console.warn('\x1b[31mnode is outdated (v' + nodeVer + '), you should install node v' + minNodeVer + '.0 or newer\x1b[0m'); } const npmVer = execSync('npm -v').toString().trim(); if (+npmVer.split('.')[0] < minNpmVer) { console.warn('\x1b[31mnpm is outdated (v' + npmVer + '), you should run:\x1b[0m'); console.warn('npm install -g npm') } execSync('npm ci', { stdio: 'inherit' }); } }