-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathbundle.ts
More file actions
35 lines (32 loc) · 853 Bytes
/
bundle.ts
File metadata and controls
35 lines (32 loc) · 853 Bytes
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
import { runHaulSync } from './runHaul';
import path from 'path';
import rimraf from 'rimraf';
export function bundleForPlatform(
projectDir: string,
platform: string,
{ ramBundle, dev = true }: { ramBundle?: boolean; dev?: boolean } = {}
) {
const bundlePath = path.resolve(
projectDir,
'dist',
platform === 'ios' ? 'index.jsbundle' : 'index.android.bundle'
);
const { stdout } = runHaulSync(projectDir, [
ramBundle ? 'ram-bundle' : 'bundle',
'--platform',
platform,
'--bundle-output',
bundlePath,
'--assets-dest',
path.resolve(projectDir, 'dist'),
'--dev',
dev ? 'true' : 'false',
]);
if (stdout.match(/(error ▶︎ |ERROR)/g)) {
throw new Error(stdout);
}
return bundlePath;
}
export function cleanup(projectDir: string) {
rimraf.sync(path.resolve(projectDir, 'dist'));
}