2021-08-28 16:48:39 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
const exec = require('child_process').exec;
|
|
|
|
|
2021-08-30 16:52:19 +08:00
|
|
|
const arkDir = path.resolve(__dirname, 'bin', "ark");
|
|
|
|
if (!fs.existsSync(arkDir)) {
|
2021-08-28 16:48:39 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isWin = !1;
|
|
|
|
let isMac = !1;
|
|
|
|
|
2021-09-11 09:38:40 +08:00
|
|
|
if (fs.existsSync(path.join(arkDir, "build-win"))) {
|
2021-08-28 16:48:39 +08:00
|
|
|
isWin = !0;
|
2021-09-11 09:38:40 +08:00
|
|
|
} else if (fs.existsSync(path.join(arkDir, "build-mac"))) {
|
2021-08-28 16:48:39 +08:00
|
|
|
isMac = !0;
|
2021-09-11 09:38:40 +08:00
|
|
|
} else if (!fs.existsSync(path.join(arkDir, "build"))) {
|
2021-08-30 16:52:19 +08:00
|
|
|
throw Error("Error: find build fail").message;
|
2021-08-28 16:48:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let cwd;
|
|
|
|
if (isWin) {
|
2021-08-30 16:52:19 +08:00
|
|
|
cwd = path.join(arkDir, "build-win");
|
2021-08-28 16:48:39 +08:00
|
|
|
} else if (isMac) {
|
2021-08-30 16:52:19 +08:00
|
|
|
cwd = path.join(arkDir, "build-mac");
|
2021-08-28 16:48:39 +08:00
|
|
|
} else {
|
2021-08-30 16:52:19 +08:00
|
|
|
cwd = path.join(arkDir, "build");
|
2021-08-28 16:48:39 +08:00
|
|
|
}
|
|
|
|
|
2022-09-25 22:01:42 +08:00
|
|
|
cwd = path.join(cwd, "legacy_api8");
|
|
|
|
|
|
|
|
exec('npm install', { cwd: cwd }, function(err, stdout, stderr) {
|
|
|
|
console.log('[31m', stdout, '[39m');
|
|
|
|
if (err !== null) {
|
|
|
|
console.error('[31m', `npm install filed: ${err}`, '[39m');
|
|
|
|
}
|
|
|
|
});
|