Skip to content

Commit

Permalink
fix: missing ensure-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
vagusX committed Jul 23, 2020
1 parent b38b1c9 commit 7ac759f
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,32 @@ class Extension {
}

async function generate() {
await fse.emptyDir(targetDir)

// copy `loader.js`
await fse.copyFile(
path.resolve(__dirname, './loaders/loader.js'),
path.resolve(targetDir, './loader.js')
)

// copy `loader-es.js`
await fse.copyFile(
path.resolve(__dirname, './loaders/loader-es.js'),
path.resolve(targetEsDir, './loader.js')
)

const extensionNames = await promisify(fs.readdir)(extensionsDir)
for (const extName of extensionNames) {
// read extension package.json
const extPath = path.resolve(extensionsDir, extName)
const extension = new Extension(extPath)
await extension.run()
try {
for (const dir of [targetDir, targetEsDir]) {
await fse.emptyDir(dir)
}
// copy `loader.js`
await fse.copyFile(
path.resolve(__dirname, './loaders/loader.js'),
path.resolve(targetDir, './loader.js')
)

// copy `loader-es.js`
await fse.copyFile(
path.resolve(__dirname, './loaders/loader-es.js'),
path.resolve(targetEsDir, './loader.js')
)

const extensionNames = await promisify(fs.readdir)(extensionsDir)
for (const extName of extensionNames) {
// read extension package.json
const extPath = path.resolve(extensionsDir, extName)
const extension = new Extension(extPath)
await extension.run()
}
} catch (err) {
console.log(err)
process.exit(128)
}
}

Expand Down

0 comments on commit 7ac759f

Please sign in to comment.