UNPKG

997 BJavaScriptView Raw
1"use strict";
2const mtldev = require("mtl-dev-sdk");
3const { consoleLog, getWorkSpace, evalJs,isWindows } = require("./m_util.js");
4const mtlLog = consoleLog;
5const mtlProject = {
6 workspace: getWorkSpace(),
7 building: undefined
8};
9
10const execJs = url => {
11 evalJs(url);
12};
13function execCommand(cmd,path) {
14 consoleLog("------shell");
15 mtldev.shellExec(cmd,path);
16}
17
18mtldev.buildAndroid = function(options, callback) {
19 _build("android", callback, options);
20};
21mtldev.buildIOS = function(options, callback) {
22 _build("ios", callback, options);
23};
24
25function _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
42module.exports = {
43 mtldev,
44 mtlLog,
45 execJs,
46 execCommand,
47 mtlProject,
48 isWindows
49};