1 | "use strict";
|
2 | const mtldev = require("mtl-dev-sdk");
|
3 | const { consoleLog, getWorkSpace, evalJs,isWindows } = require("./m_util.js");
|
4 | const mtlLog = consoleLog;
|
5 | const mtlProject = {
|
6 | workspace: getWorkSpace(),
|
7 | building: undefined
|
8 | };
|
9 |
|
10 | const execJs = url => {
|
11 | evalJs(url);
|
12 | };
|
13 | function execCommand(cmd,path) {
|
14 | consoleLog("------shell");
|
15 | mtldev.shellExec(cmd,path);
|
16 | }
|
17 |
|
18 | mtldev.buildAndroid = function(options, callback) {
|
19 | _build("android", callback, options);
|
20 | };
|
21 | mtldev.buildIOS = function(options, callback) {
|
22 | _build("ios", callback, options);
|
23 | };
|
24 |
|
25 | function _build(pla, callback, options) {
|
26 | mtlProject.building = `编译坏境 正在 build ${pla} ,请等待。。。。`;
|
27 | mtlLog(mtlProject.building);
|
28 | try {
|
29 | mtldev.build(
|
30 | pla,
|
31 | function(res) {
|
32 | mtlProject.building = undefined;
|
33 | callback(res);
|
34 | },
|
35 | options
|
36 | );
|
37 | } catch (e) {
|
38 | mtldev(e);
|
39 | }
|
40 | }
|
41 |
|
42 | module.exports = {
|
43 | mtldev,
|
44 | mtlLog,
|
45 | execJs,
|
46 | execCommand,
|
47 | mtlProject,
|
48 | isWindows
|
49 | };
|