git ssb

1+

mixmix / scuttle-shell



Tree: 4933e4b778bdb7bc249725e152a78612fe6fcb5c

Files: 4933e4b778bdb7bc249725e152a78612fe6fcb5c / scripts / setup.js

1286 bytesRaw
1var homedir = require('os').homedir()
2var path = require('path')
3var fs = require('fs')
4var mkdirp = require('mkdirp')
5
6var appPath = path.join(__dirname, '../host-app.js')
7
8function setup () {
9 if (process.platform === 'win32') {
10 console.log("This script doesn't work on windows, try npm run setup-win")
11 return 1
12 }
13
14 if (!fs.existsSync(appPath)) {
15 console.log('[ERROR] Application not found at: ', appPath)
16 return 1
17 }
18
19 var manifest = buildManifest()
20 setupMozillaManifest(manifest)
21
22 return 0
23}
24
25function buildManifest () {
26 const template = require(path.join(__dirname, '../scuttleshell.template.json'))
27 return Object.assign(template, { path: appPath })
28}
29
30function setupMozillaManifest (manifest) {
31 var manifestFolderPath = process.platform === 'darwin'
32 ? path.join(homedir, '/Library/Application Support/Mozilla/NativeMessagingHosts')
33 : path.join(homedir, '/.mozilla/native-messaging-hosts')
34
35 mkdirp.sync(manifestFolderPath)
36
37 fs.writeFileSync(
38 path.join(manifestFolderPath, 'scuttleshell.json'),
39 JSON.stringify(manifest, null, 2)
40 )
41
42 console.log('[OK] Wrote manifest path to registry.\n[INFO] Try: npm run check')
43}
44
45module.exports = setup
46
47if (require.main === module) {
48 var errorLevel = setup()
49 process.exit(errorLevel)
50}
51

Built with git-ssb-web