Getting dependency installation working correctly.
This commit is contained in:
parent
ba16af1daa
commit
22ce84f384
|
@ -102,4 +102,6 @@ packages/builder/cypress/reports
|
||||||
stats.html
|
stats.html
|
||||||
|
|
||||||
# TypeScript cache
|
# TypeScript cache
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
budibase-component
|
||||||
|
budibase-datasource
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const util = require("util")
|
const util = require("util")
|
||||||
const exec = util.promisify(require("child_process").exec)
|
const exec = util.promisify(require("child_process").exec)
|
||||||
|
|
||||||
exports.exec = async command => {
|
exports.exec = async (command, dir = "./") => {
|
||||||
const { stdout } = await exec(command)
|
const { stdout } = await exec(command, { cwd: dir })
|
||||||
return stdout
|
return stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,13 @@ exports.utilityInstalled = async utilName => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.runPkgCommand = async command => {
|
exports.runPkgCommand = async (command, dir = "./") => {
|
||||||
const yarn = await exports.utilityInstalled("yarn")
|
const yarn = await exports.utilityInstalled("yarn")
|
||||||
const npm = await exports.utilityInstalled("npm")
|
const npm = await exports.utilityInstalled("npm")
|
||||||
if (!yarn && !npm) {
|
if (!yarn && !npm) {
|
||||||
throw new Error("Must have yarn or npm installed to run build.")
|
throw new Error("Must have yarn or npm installed to run build.")
|
||||||
}
|
}
|
||||||
const npmCmd = command === "install" ? `npm ${command}` : `npm run ${command}`
|
const npmCmd = command === "install" ? `npm ${command}` : `npm run ${command}`
|
||||||
await exports.exec(yarn ? `yarn ${command}` : npmCmd)
|
const cmd = yarn ? `yarn ${command}` : npmCmd
|
||||||
|
await exports.exec(cmd, dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ async function init(opts) {
|
||||||
await getSkeleton(type, name)
|
await getSkeleton(type, name)
|
||||||
await fleshOutSkeleton(name, desc, version)
|
await fleshOutSkeleton(name, desc, version)
|
||||||
console.log(info("Installing dependencies..."))
|
console.log(info("Installing dependencies..."))
|
||||||
await runPkgCommand("install")
|
await runPkgCommand("install", join(process.cwd(), name))
|
||||||
console.log(info(`Plugin created in directory "${name}"`))
|
console.log(info(`Plugin created in directory "${name}"`))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue