Skip to content

Commit

Permalink
build-plugins.js: minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored and GeoSot committed Oct 3, 2021
1 parent 70cf0c2 commit 010d0dd
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions build/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ for (const filePath of paths) {
resolved[filenameToEntity(path.basename(filePath, '.js'))] = {
src: filePath.replace('.js', ''),
dist: filePath.replace('src', 'dist'),
name: filePath.replace(`${srcPath}/`, '')
name: path.relative(srcPath, filePath)
}
}

Expand All @@ -42,7 +42,6 @@ const plugins = [
]

const build = async pluginKey => {
console.log(`Building ${pluginKey} plugin...`)
const plugin = resolved[pluginKey]

const globals = {}
Expand All @@ -58,16 +57,16 @@ const build = async pluginKey => {
}

// eslint-disable-next-line no-unused-vars
const usedPlugin = Object.entries(resolved).find(([key, path]) => {
return path.src.includes(source.replace(pattern, ''))
const usedPlugin = Object.entries(resolved).find(([key, p]) => {
return p.src.includes(source.replace(pattern, ''))
})

if (!usedPlugin) {
console.warn(`Source ${source} is not mapped`)
return false
}

globals[usedPlugin[1].src] = usedPlugin[0]
globals[path.normalize(usedPlugin[1].src)] = usedPlugin[0]
return true
}
})
Expand All @@ -84,13 +83,19 @@ const build = async pluginKey => {
console.log(`Building ${pluginKey} plugin... Done!`)
}

const main = () => {
(async () => {
try {
Promise.all(Object.keys(resolved).map(plugin => build(plugin)))
const basename = path.basename(__filename)
const timeLabel = `[${basename}] finished`

console.log('Building individual plugins...')
console.time(timeLabel)

await Promise.all(Object.keys(resolved).map(plugin => build(plugin)))

console.timeEnd(timeLabel)
} catch (error) {
console.error(error)
process.exit(1)
}
}

main()
})()

0 comments on commit 010d0dd

Please sign in to comment.