git ssb

1+

mixmix / scuttle-shell



Tree: a4903851ba301b852a1888eff0b525e81f2f6646

Files: a4903851ba301b852a1888eff0b525e81f2f6646 / scripts / setup-win.js

1631 bytesRaw
1
2var path = require('path')
3var regedit = require('regedit')
4var fs = require("fs")
5var appPath = path.resolve(".\\app.bat")
6var appManifestTemplateFile = path.resolve(".\\scuttleshell.template.json")
7var appManifestFile = path.resolve(".\\scuttleshell.json")
8
9
10function setup(cb) {
11
12 if (process.platform !== "win32") {
13 console.log("This script works only on windows, try npm run setup")
14 cb(1)
15 }
16
17 if (!fs.existsSync(appPath)) {
18 console.log("[ERROR] Application not found at: ", appPath)
19 cb(1)
20 }
21
22 if (!fs.existsSync(appManifestTemplateFile)) {
23 console.log("[ERROR] App manifest not found at: ", appManifestTemplateFile)
24 cb(1)
25 }
26
27 let manifestTemplate = JSON.parse(fs.readFileSync(appManifestTemplateFile))
28
29 manifestTemplate.path = appPath
30 fs.writeFileSync(appManifestFile, JSON.stringify(manifestTemplate))
31
32
33 // This now involves writing to the registry, I am a bit scared of that...
34
35 var valuesToPut = {
36 'HKCU\\Software\\Mozilla\\NativeMessagingHosts\\scuttleshell': {
37 'scuttleshell': {
38 value: appManifestFile,
39 type: 'REG_DEFAULT'
40 }
41 }
42 }
43
44 regedit.createKey('HKCU\\Software\\Mozilla\\NativeMessagingHosts\\scuttleshell', function (a, b) {
45 regedit.putValue(valuesToPut, function (err) {
46 if (err) {
47 console.log("[ERROR] Problem writing to registry.", err)
48 cb(1)
49 } else {
50 console.log("[OK] Wrote manifest path to registry.\n[INFO] Try: npm run check-win")
51 cb(0)
52 }
53 })
54 })
55}
56
57module.exports = setup
58
59if (require.main === module) {
60 setup((errorLevel) => {
61 process.exit(errorLevel)
62 })
63}
64
65

Built with git-ssb-web