git ssb

1+

mixmix / scuttle-shell



Tree: c3840081d9c3529672b66b5d47b2013475fc783c

Files: c3840081d9c3529672b66b5d47b2013475fc783c / scripts / setup.js

1746 bytesRaw
1
2
3var homedir = require('os').homedir()
4var path = require('path')
5var macPath = homedir + "/Library/Application Support/Mozilla/NativeMessagingHosts/scuttleshell.json"
6var linuxPath = homedir + "/.mozilla/native-messaging-hosts/scuttleshell.json"
7var manifestPath = process.platform === "darwin" ? macPath : linuxPath
8var manifestFolderPath = manifestPath.replace("scuttleshell.json", "")
9var appPath = path.resolve("../host-app.js")
10var localManifestFile = path.resolve("../scuttleshell.json")
11var fs = require("fs")
12var mkdirp = require("mkdirp")
13
14function setup() {
15
16 if (process.platform == "win32") {
17 console.log("This script doesn't work on windows, try npm run setup-win")
18 return 1
19 }
20
21 if (!fs.existsSync(appPath)) {
22 console.log("[ERROR] Application not found at: ", appPath)
23 return 1
24 }
25
26 if (!fs.existsSync(localManifestFile)) {
27 console.log("[ERROR] Local copy of app manifest not found at: ", localManifestFile)
28 return 1
29 }
30
31 let manifest = JSON.parse(fs.readFileSync(localManifestFile))
32
33 let applicationLauncherPath = manifest.path
34
35 if (!fs.existsSync(applicationLauncherPath)) {
36 console.log("[ERROR] App not found at declared location", applicationLauncherPath)
37 console.log("FIXING...")
38 manifest.path = appPath
39 fs.writeFileSync(localManifestFile, JSON.stringify(manifest))
40 } else {
41 console.log("[OK] Application found at the correct location", applicationLauncherPath)
42 }
43
44 mkdirp.sync(manifestFolderPath)
45 fs.writeFileSync(manifestPath, JSON.stringify(manifest))
46
47 console.log("[OK] Wrote manifest path to registry.\n[INFO] Try: npm run check")
48 return 0
49}
50
51module.exports = setup
52
53if (require.main === module) {
54 var errorLevel = setup()
55 process.exit(errorLevel)
56}
57

Built with git-ssb-web