c25f88492b
I had an issue where the datasource plugin wouldn't work because of node engine incompatibility, and after a quick search on google I found that --ignore-engines is the option to use for ignoring this kind of error and it worked! So I want to make this a built-in feature so there's no need for me to manually do this.
27 lines
810 B
JavaScript
27 lines
810 B
JavaScript
const util = require("util")
|
|
const exec = util.promisify(require("child_process").exec)
|
|
|
|
exports.exec = async (command, dir = "./") => {
|
|
const { stdout } = await exec(command, { cwd: dir })
|
|
return stdout
|
|
}
|
|
|
|
exports.utilityInstalled = async utilName => {
|
|
try {
|
|
await exports.exec(`${utilName} --version`)
|
|
return true
|
|
} catch (err) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
exports.runPkgCommand = async (command, dir = "./") => {
|
|
const yarn = await exports.utilityInstalled("yarn")
|
|
const npm = await exports.utilityInstalled("npm")
|
|
if (!yarn && !npm) {
|
|
throw new Error("Must have yarn or npm installed to run build.")
|
|
}
|
|
const npmCmd = command === "install" ? `npm ${command}` : `npm run ${command}`
|
|
const cmd = yarn ? `yarn ${command} --ignore-engines` : npmCmd
|
|
await exports.exec(cmd, dir)
|
|
}
|