-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.js
51 lines (37 loc) · 1.51 KB
/
plugin.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
// Ignite CLI plugin for Standard
// ----------------------------------------------------------------------------
const NPM_MODULE_NAME = 'standard'
const NPM_MODULE_VERSION = '10.0.2'
const PARSER = 'babel-eslint'
const PRETTIFIER = 'snazzy'
const PARSER_VERSION = '7.1.1'
const APP_PATH = process.cwd()
const PLUGIN_PATH = __dirname
const patches = require(`${PLUGIN_PATH}/patches`)
const add = async function (context) {
const { ignite, filesystem } = context
await ignite.addModule(NPM_MODULE_NAME, { link: true, dev: true, version: NPM_MODULE_VERSION })
await ignite.addModule(PRETTIFIER, { dev: true })
await ignite.addModule(PARSER, { dev: true, version: PARSER_VERSION })
let pkg = filesystem.read(`${APP_PATH}/package.json`, 'json')
pkg.scripts['lint'] = patches.lint
pkg.scripts['lintdiff'] = patches.lintdiff
pkg.scripts['fixcode'] = patches.fixcode
pkg.standard = patches.standard
filesystem.write(`${APP_PATH}/package.json`, pkg)
}
const remove = async function (context) {
const { ignite, filesystem } = context
// remove the npm module and unlink it
await ignite.removeModule(NPM_MODULE_NAME, { unlink: true })
await ignite.removeModule(PRETTIFIER)
await ignite.removeModule(PARSER)
let pkg = filesystem.read(`${APP_PATH}/package.json`, 'json')
delete pkg.scripts['lint']
delete pkg.scripts['lintdiff']
delete pkg.scripts['fixcode']
delete pkg['standard']
filesystem.write(`${APP_PATH}/package.json`, pkg)
}
// Required in all Ignite CLI plugins
module.exports = { add, remove }