-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
51 lines (43 loc) · 1.15 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
51
#!/usr/bin/env node
import isCI from 'is-ci'
import { log, cliOptions } from './helper'
import { configure } from './configure'
import { lint } from './script/lint'
import { native } from './script/native'
import { apply } from './script/apply'
import { patch } from './script/patch'
import { plugin } from './script/plugin'
import { android } from './script/android'
import { ios } from './script/ios'
import { prompt } from './script/prompt'
export type { PluginInput } from './types'
const scripts = {
lint,
native,
apply,
patch,
plugin,
android,
ios,
prompt,
}
const script = process.argv.slice(2)[0] ?? 'prompt'
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))
} catch (error) {
log(`Script ${script} exited with an error`)
if (script !== 'test' && !isCI) {
// eslint-disable-next-line no-console
console.error(error)
}
if (isCI) {
throw new Error(error)
}
}