-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
55 lines (46 loc) · 1.82 KB
/
setup.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
52
53
54
55
#!/usr/bin/env node
const {Setup} = require("web-ext-native-msg")
const path = require('path')
const fs = require('fs-extra')
const handlerAfterSetup = info => {
const {configDirPath, shellScriptPath, manifestPath} = info;
console.log('-----')
console.log('The Scuttle Shell Browser host has been installed.')
console.log('Install the Scuttle Shell Browser Firefox Add-on if you haven\'t already.')
console.log('You can download the Add-On here: https://github.com/retog/scuttle-shell-browser/releases/tag/1.0.0')
};
const getProjectRoot = () => {
const [, binPath] = process.argv;
const scriptPath = fs.realpathSync(binPath);
const root = path.resolve(path.dirname(scriptPath), './');
return root;
};
const getMainScriptPath = () => {
const [, binPath] = process.argv;
const scriptPath = fs.realpathSync(binPath);
const mainScriptPath = path.resolve(path.dirname(scriptPath), 'host-script.js');
console.log('mainScriptPath: '+mainScriptPath)
return mainScriptPath;
};
const setup = new Setup({
hostDescription: "Exposes an ssb-client to the scuttle shell browser extension",
browser: "firefox",
hostName: "scuttle_shell_browser",
mainScriptFile: getMainScriptPath(),
chromeExtensionIds: ["chrome-extension://xxxxxx"],
webExtensionIds: ["[email protected]"],
overwriteConfig: true,
callback: handlerAfterSetup,
});
const origCreateShellFunction = setup._createShellScript
setup._createShellScript = async function(configDir) {
const targetPath = path.resolve(configDir, 'app')
fs.ensureDir(targetPath)
await fs.copy(getProjectRoot(), targetPath, {
overwrite: true,
filter: (src,dest) => !~src.indexOf('/.git') && !~src.indexOf('/.bin')
})
setup.mainScriptFile = path.resolve(targetPath, './host-script.js')
return origCreateShellFunction.apply(setup, [configDir])
}
setup.run();