This repository was archived by the owner on Sep 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
67 lines (61 loc) · 1.83 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const Async = require('async');
const Path = require('fire-path');
const Fs = require('fire-fs');
module.exports = {
load () {
},
unload () {
},
messages: {
'editor:build-start'(event, options){
},
'editor:build-finished'(event, options) {
try{
let tasks = options.sdkList;
let dest = '';
if(options.platform == "web-mobile") {
dest = Path.join(options.dest, options.platform);
}else{
dest = Path.join(options.dest, 'jsb-' + options.template);
}
let opts = {
cwd: dest
};
Async.eachSeries(tasks, function (task, done) {
if(task.checked){
let projectJsonPath = Path.join(dest, '.cocos-package.json');
let value = task.value;
if (Fs.existsSync(projectJsonPath)){
let json = JSON.parse(Fs.readFileSync(projectJsonPath));
if(json[value] && options.platform != "web-mobile") {
done();
return ;
}
}
Editor.log('Import ' + task.text + ' to ' + dest);
let args = ['package', 'import', '-b', value, '--runincocos', '-v'];
let child = Editor.NativeUtils.getCocosSpawnProcess(args, opts);
child.stdout.on('data', (data) => {
Editor.log(data.toString());
});
child.on('close', (code, signal) => {
done();
});
child.on('error', function (err) {
Editor.error(err);
done();
});
}else{
done();
}
}, function (err) {
if (err) Editor.error(err);
});
}
catch (err) {
Editor.error(err);
}
}
},
};