forked from ipatalas/vscode-postfix-ts
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtasks.js
30 lines (24 loc) · 814 Bytes
/
tasks.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
const fs = require('fs')
const LANGUAGE = 'postfix'
const ACTIVATION_EVENT = `onLanguage:${LANGUAGE}`
const task = process.argv.length > 2 && process.argv[2]
const tasksMap = new Map([
['prerun', prerun],
['pretest', pretest]
])
function prerun() {
let pkg = readPackageJson()
delete pkg.contributes.languages
pkg.activationEvents = ['*']
writePackageJson(pkg)
}
function pretest() {
let pkg = readPackageJson()
pkg.contributes.languages = [{id: LANGUAGE}]
pkg.activationEvents = [ACTIVATION_EVENT]
writePackageJson(pkg)
}
const writePackageJson = (content) => fs.writeFileSync('./package.json', JSON.stringify(content, undefined, '\t'))
const readPackageJson = () => require('./package.json')
const taskToExecute = tasksMap.get(task)
taskToExecute && taskToExecute()