-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor run-exec-ncu.js to enhance functionality and remove deprecat…
…ed script; update README.md to document dependabot branch deletions
- Loading branch information
charlie on CascadeTrails
committed
Oct 19, 2024
1 parent
a613312
commit 5d3ffb2
Showing
3 changed files
with
119 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 characters
This file was deleted.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,69 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const { log } = require('console'); | ||
const execNcu = require('./exec-ncu'); | ||
const execProgram = require('./utils'); | ||
const { readFileSync } = require('fs'); | ||
const { exec } = require('child_process'); | ||
const { cwd } = require('process'); | ||
|
||
log('runNcu starting', execNcu); | ||
log('runNcu starting', runNcu); // Function | ||
|
||
execNcu.runNcu(); | ||
log("__dirName:", __dirname); | ||
log("__filename:", __filename); | ||
|
||
data = readFileSync(__dirname + '/audit-check/auditDataReports.json', 'utf8', (err, data) => { | ||
if (err) { | ||
console.error(`Error reading file: ${err.message}`); | ||
return; | ||
} | ||
|
||
log('Data:', data); | ||
}); | ||
|
||
log('Data:', data); | ||
const dataAry = JSON.parse(data); | ||
log('TypeOf Data:', typeof dataAry); | ||
log('Data:', dataAry[0]); | ||
log('Data:', dataAry[1]); | ||
|
||
|
||
|
||
// How can I run this loop safely with no emitter errors? | ||
/* for (let i = 0; i < dataAry.length; i += 1) { | ||
process.chdir(path.dirname(dataAry[i])); | ||
runNcu(); | ||
} */ | ||
|
||
function runNcu() { | ||
return new Promise((resolve, reject) => { | ||
exec('ncu', (error, stdout, stderr) => { | ||
if (error) { | ||
reject(`Error: ${stderr}`); | ||
} else { | ||
const output = stdout; | ||
if (output.includes('No package.json file found')) { | ||
reject(`Error: ${output}`); | ||
} | ||
if (output.includes('Run ncu -u to upgrade package.json')) { | ||
log('need to upgrade', cwd()); | ||
} | ||
console.log(output); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function runLoopSafely(dataAry) { | ||
for (let i = 0; i < dataAry.length; i += 1) { | ||
process.chdir(path.dirname(dataAry[i])); | ||
try { | ||
const result = await runNcu(); | ||
console.log("result:", result); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
} | ||
|
||
runLoopSafely(dataAry); |