mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
build all packages
This commit is contained in:
1 parent
592302975f
commit
9a6e3e0fb6
17 files changed
+49
-46
No files matched your search
+11
-7
@@ -8,6 +8,10 @@ const creatRollupConfig = require('./creatRollupConfig');
|
||||
|
||||
const isBuildAll = process.argv.pop() === 'all';
|
||||
|
||||
function runPromisesInSeries(ps) {
|
||||
return ps.reduce((p, next) => p.then(next), Promise.resolve());
|
||||
}
|
||||
|
||||
function build(projectPath) {
|
||||
const { input, output, plugins } = creatRollupConfig(projectPath);
|
||||
const dist = path.join(projectPath, 'dist');
|
||||
@@ -19,7 +23,7 @@ function build(projectPath) {
|
||||
input,
|
||||
plugins,
|
||||
})
|
||||
.then(bundle => {
|
||||
.then((bundle) => {
|
||||
bundle.write(output);
|
||||
logger.success(`finished building all bundles from ${projectPath}`);
|
||||
});
|
||||
@@ -28,19 +32,19 @@ function build(projectPath) {
|
||||
|
||||
if (isBuildAll) {
|
||||
const bundles = [];
|
||||
Object.keys(projects).forEach(item => {
|
||||
Object.keys(projects).forEach((item) => {
|
||||
const projectPath = projects[item];
|
||||
bundles.push(build(projectPath));
|
||||
bundles.push(() => build(projectPath));
|
||||
});
|
||||
|
||||
const dist = path.join(process.cwd(), 'dist');
|
||||
del(dist).then(() => {
|
||||
logger.success(`----Delete directory successfully: ${dist}----`);
|
||||
Promise.all(bundles)
|
||||
runPromisesInSeries(bundles)
|
||||
.then(() => {
|
||||
logger.success('----finished building all packages----');
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
logger.fatal(err);
|
||||
});
|
||||
});
|
||||
@@ -54,10 +58,10 @@ if (isBuildAll) {
|
||||
choices: Object.keys(projects),
|
||||
},
|
||||
])
|
||||
.then(answers => {
|
||||
.then((answers) => {
|
||||
build(projects[answers.project]);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
logger.fatal(err);
|
||||
});
|
||||
}
|
||||
@@ -2,10 +2,9 @@ const path = require('path');
|
||||
const glob = require('glob');
|
||||
|
||||
module.exports = function getProjects() {
|
||||
const projects = {};
|
||||
glob.sync(path.join(process.cwd(), 'packages/*')).forEach(item => {
|
||||
return glob.sync(path.join(process.cwd(), 'packages/*')).reduce((result, item) => {
|
||||
const name = item.split(path.sep).pop();
|
||||
projects[name] = item;
|
||||
});
|
||||
return projects;
|
||||
result[name] = item;
|
||||
return result;
|
||||
}, {});
|
||||
};
|
||||
Reference in new issue
Block a user