-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
60 lines (51 loc) · 1.67 KB
/
gulpfile.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
const dotenv = require('dotenv');
const path = require('path');
function setupDotEnv() {
const results = [
dotenv.config({
path: path.resolve(__dirname, './.env'),
}),
];
const errorResult = results.find((result) => result.error);
if (errorResult) {
throw errorResult.error;
}
}
setupDotEnv();
const gulp = require('gulp');
const { execSync, exec } = require('child_process');
function execCmd(cmd) {
return execSync(cmd, { stdio: 'inherit' });
}
function build(cb) {
exec('yarn start', { stdio: 'inherit' });
cb();
}
function buildInjected(cb) {
const appPath = process.env.APP_MONOREPO_LOCAL_PATH;
if (!appPath) {
throw new Error('APP_MONOREPO_LOCAL_PATH not found, please set it at .env file');
}
const currentPath = __dirname;
// execSync('yarn build-inject');
execCmd('cd packages/injected && yarn build && cd -');
execCmd(`APP_MONOREPO_LOCAL_PATH=${appPath} CURRENT_WORKING_PATH=${currentPath} sh rsync-npm.sh`);
execCmd(`cd ${appPath} && yarn copy:inject && cd -`);
execCmd('echo ">>>>>>>>>>>>>>> "');
execCmd(
'echo "\t Manually update app-monorepo WebView.js comment hash in code make iOS hot-reload take effect."',
);
execCmd(
'echo "\t Manually update app-monorepo content-script.ts comment hash in code make EXT hot-reload take effect. Or use content-script reload button to force reload extension."',
);
execCmd('echo ">>>>>>>>>>>>>>> "');
cb();
}
function watching(cb) {
gulp.watch(['packages/**/src/**/*.ts', 'packages/**/src/**/*.tsx'], buildInjected);
cb();
}
const watch = gulp.series(buildInjected, watching);
exports.default = buildInjected;
exports.build = buildInjected;
exports.watch = watch;