-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
50 lines (42 loc) · 1.13 KB
/
index.ts
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
#!/usr/bin/env bun
import isCi from 'is-ci'
import { configure } from './configure'
import { cliOptions, log } from './helper'
import { android } from './script/android'
import { apply } from './script/apply'
import { ios } from './script/ios'
import { lint } from './script/lint'
import { native } from './script/native'
import { patch } from './script/patch'
import { plugin } from './script/plugin'
import { prompt } from './script/prompt'
export type { PluginInput, PluginLog } from './types'
const scripts = {
lint,
native,
apply,
patch,
plugin,
android,
ios,
prompt,
}
const script = (process.argv.slice(2)[0] ?? 'prompt') as keyof typeof scripts
if (!Object.keys(scripts).includes(script)) {
log('Please provide a valid script', 'error')
}
// Configure package.json (again) before each script is run.
// Also copies over user made configuration possibly required
// for script to run properly.
await configure()
try {
scripts[script](cliOptions(script) as any)
} catch (error: any) {
log(`Script ${script} exited with an error`)
if (!isCi) {
log(error, 'warning')
}
if (isCi) {
throw new Error(error)
}
}