-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from xtremespb/core_030821
Bugfixes
- Loading branch information
Showing
80 changed files
with
5,718 additions
and
8,942 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
"mform", | ||
"mnotify", | ||
"mtable", | ||
"npmi", | ||
"ratelimit", | ||
"rerr", | ||
"rspace", | ||
|
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 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 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 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const path = require("path"); | ||
const fs = require("fs-extra"); | ||
const semver = require("semver"); | ||
const { | ||
exec | ||
} = require("child_process"); | ||
const { | ||
format, | ||
} = require("date-fns"); | ||
|
||
class NPMI { | ||
async isInstalled(name, version = "latest") { | ||
try { | ||
const packageJSON = await fs.readJSON(path.resolve(__dirname, "..", "node_modules", name, "package.json")); | ||
const packageJSONVersion = semver.coerce(packageJSON.version); | ||
const needVersion = semver.coerce(version); | ||
return semver.gte(packageJSONVersion, needVersion) ? packageJSON.version : false; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
async execCommand(cmd) { | ||
return new Promise((resolve, reject) => { | ||
let exitCode; | ||
const workerProcess = exec(cmd, (error, stdout, stderr) => { | ||
if (exitCode === 0) { | ||
// eslint-disable-next-line no-control-regex | ||
fs.writeFileSync(path.resolve(`${__dirname}/../logs/build_${format(new Date(), "yyyyMMdd_HHmmss")}.log`), stdout.replace(/[^\x00-\x7F]/g, "")); | ||
resolve(stdout); | ||
} else { | ||
// eslint-disable-next-line prefer-promise-reject-errors | ||
reject(new Error(`${stdout || ""}${stderr || ""}`)); | ||
} | ||
}); | ||
workerProcess.on("exit", code => exitCode = code); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = NPMI; |
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
Oops, something went wrong.