Last active
July 4, 2024 19:29
-
-
Save dbritto-dev/36699fae284bdc90066e37517105141c to your computer and use it in GitHub Desktop.
Revisions
-
dbritto-dev revised this gist
Jul 4, 2024 . 1 changed file with 9 additions and 9 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 @@ -6,20 +6,18 @@ const dependencies = Object.keys(pkg.dependencies || {}); const devDependencies = Object.keys(pkg.devDependencies || {}); const pkgRegex = new RegExp(process.argv.slice(2)[0]); const latestDependencies = dependencies .concat(devDependencies) .filter((dependency) => pkgRegex.test(dependency)) .map((dependency) => `${dependency}@latest`); if (latestDependencies.length > 0) { const npmInstall = spawn("npm", ["install"].concat(latestDependencies)); npmInstall.on("close", (code) => { if (code === 0) { console.info( `The next packages were updated to their latest version:\n${latestDependencies.join( "\n" )}` ); @@ -28,6 +26,8 @@ if (filteredDependencies.length > 0) { } }); } else { console.log( `No packages found with the next regular expression: ${pkgRegex}` ); process.exit(1); } -
dbritto-dev renamed this gist
Jul 4, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dbritto-dev created this gist
Jul 4, 2024 .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,33 @@ /* eslint-disable unicorn/no-process-exit */ const { spawn } = require("child_process"); const pkg = require("./package.json"); const dependencies = Object.keys(pkg.dependencies || {}); const devDependencies = Object.keys(pkg.devDependencies || {}); const pkgRegex = new RegExp(process.argv.slice(2)[0]); const filteredDependencies = dependencies .concat(devDependencies) .filter((dependency) => pkgRegex.test(dependency)); const latestDependencies = filteredDependencies.map( (dependency) => `${dependency}@latest` ); if (filteredDependencies.length > 0) { const npmInstall = spawn("npm", ["install", ...latestDependencies]); npmInstall.on("close", (code) => { if (code === 0) { console.info( `The next packages were updated to their latest version:\n${filteredDependencies.join( "\n" )}` ); } else { console.error(`Something went wrong`); } }); } else { console.log(`No matches found with the next regular expression: ${pkgRegex}`); process.exit(1); }