Skip to content

Commit 21ad540

Browse files
committed
fix(build & cli): runtime copy error and h5skip option
1 parent b5654f5 commit 21ad540

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

packages/mars-build/src/compiler/runtime/compiler.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ function compile(options) {
4141
entry = require.resolve('@marsjs/core/src/h5', {
4242
paths: [process.cwd()]
4343
});
44-
return Promise.all([
45-
// fs.copy(entry, coreDestDir + '/index.js'),
46-
fs.copy(path.dirname(entry), path.resolve(process.cwd(), destPath))
47-
]);
44+
const entryDir = path.dirname(entry);
45+
const files = fs.readdirSync(entryDir);
46+
return Promise.all(files.map(file => fs.copy(
47+
path.resolve(entryDir, file),
48+
path.resolve(process.cwd(), destPath, file)
49+
)));
4850
}
4951
else {
5052
return Promise.resolve();

packages/mars-build/src/scripts/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function getBuildTasks(config = {}, options = {}) {
3737
// if (target !== 'h5') {
3838
gulp.task('compile:runtime', getTaskRuntime(config, options));
3939
buildTasks.push('compile:runtime');
40-
// }
40+
// // }
4141

4242
return buildTasks;
4343
}

packages/mars-cli/bin/mars-build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ program
1414
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
1515
.option('-t, --target <target>', 'Build target (swan | h5 | wx, default: swan)')
1616
.option('-w, --watch', 'Open watch mode')
17-
.option('--skipMars', 'Skip mars compile process, directly call vue cli serve')
17+
.option('--h5skip <process>', 'Skip h5 compile process (mars | vue)')
1818
.action(cmd => {
1919
const build = require('../lib/build');
2020
const options = cleanArgs(cmd);

packages/mars-cli/bin/mars-serve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ program
1313
.description('serve project in development mode')
1414
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
1515
.option('-t, --target <target>', 'Build target (swan | h5 | wx, default: swan)')
16-
.option('--skipMars', 'Skip mars compile process, directly call vue cli serve')
16+
.option('--h5skip <process>', 'Skip h5 compile process (mars | vue)')
1717
.action(cmd => {
1818
const start = require('../lib/serve');
1919
const options = cleanArgs(cmd);

packages/mars-cli/bin/mars.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ program
188188
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
189189
.option('-t, --target <target>', 'Build target (swan | h5 | wx, default: swan)')
190190
.option('-w, --watch', 'Open watch mode')
191-
.option('--skipMars', 'Skip mars compile process, directly call vue cli serve')
191+
.option('--h5skip <process>', 'Skip h5 compile process (mars | vue)')
192192
.action(cmd => {
193193
const options = cleanArgs(cmd);
194194
const buildPath = path.resolve(__dirname, './mars-build.js');
@@ -204,7 +204,7 @@ program
204204
if (options[op] !== false) {
205205
args.push('--' + op);
206206
if (options[op] !== true) {
207-
args.push(options.op);
207+
args.push(options[op]);
208208
}
209209
}
210210
});
@@ -220,7 +220,7 @@ program
220220
.description('serve project in development mode')
221221
.option('-r, --registry <url>', 'Use specified npm registry when installing dependencies (only for npm)')
222222
.option('-t, --target <target>', 'Build target (swan | h5 | wx, default: swan)')
223-
.option('--skipMars', 'Skip mars compile process, directly call vue cli serve')
223+
.option('--h5skip <process>', 'Skip h5 compile process (mars | vue)')
224224
.action(cmd => {
225225
const options = cleanArgs(cmd);
226226
const buildPath = path.resolve(__dirname, './mars-serve.js');
@@ -236,7 +236,7 @@ program
236236
if (options[op] !== false) {
237237
args.push('--' + op);
238238
if (options[op] !== true) {
239-
args.push(options.op);
239+
args.push(options[op]);
240240
}
241241
}
242242
});

packages/mars-cli/lib/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ async function build(cmd) {
4747
child.stderr.pipe(process.stderr);
4848
}
4949

50-
if (target === 'h5' && cmd.skipMars) {
50+
if (target === 'h5' && cmd.h5skip === 'mars') {
5151
return serveH5();
5252
}
5353

5454
const run = cmd.watch ? watch : build;
5555

5656
clean(options).once('stop', () => {
5757
run(options).once('stop', () => {
58-
if (target === 'h5') {
58+
if (target === 'h5' && cmd.h5skip !== 'vue') {
5959
serveH5();
6060
}
6161
else {

packages/mars-cli/lib/serve.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ async function start(cmd) {
4646
child.stderr.pipe(process.stderr);
4747
}
4848

49-
if (target === 'h5' && cmd.skipMars) {
49+
if (target === 'h5' && cmd.h5skip === 'mars') {
5050
return serveH5();
5151
}
5252

5353
clean(options).once('stop', () => {
5454
watch(options).once('stop', () => {
55-
if (target === 'h5') {
55+
if (target === 'h5' && cmd.h5skip !== 'vue') {
5656
serveH5();
5757
}
5858
else {

0 commit comments

Comments
 (0)