Getting dependency installation working correctly.
This commit is contained in:
parent
c9c468a424
commit
1f2f130907
|
@ -102,4 +102,6 @@ packages/builder/cypress/reports
|
|||
stats.html
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
*.tsbuildinfo
|
||||
budibase-component
|
||||
budibase-datasource
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const util = require("util")
|
||||
const exec = util.promisify(require("child_process").exec)
|
||||
|
||||
exports.exec = async command => {
|
||||
const { stdout } = await exec(command)
|
||||
exports.exec = async (command, dir = "./") => {
|
||||
const { stdout } = await exec(command, { cwd: dir })
|
||||
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 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}`
|
||||
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 fleshOutSkeleton(name, desc, version)
|
||||
console.log(info("Installing dependencies..."))
|
||||
await runPkgCommand("install")
|
||||
await runPkgCommand("install", join(process.cwd(), name))
|
||||
console.log(info(`Plugin created in directory "${name}"`))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue