Skip to content

Commit

Permalink
Copyng app to config-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
retog committed Dec 23, 2020
1 parent 5bdbbfb commit 623c4c8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
36 changes: 16 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "rollup -c",
"run:browser": "web-ext run --no-reload --bc -v -u \"http://localhost:9090/product-review.html\" -u \"about:debugging#/runtime/this-firefox\" --source-dir ./webext/",
"run:server": "http-server site -p 9090",
"run:server": "http-server site --cors -p 9090",
"run": "run-p run:*",
"webext:build": "web-ext build",
"webext:sign": "web-ext sign --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRET",
Expand All @@ -19,6 +19,7 @@
"license": "ISC",
"dependencies": {
"buffer": "^6.0.3",
"fs-extra": "^9.0.1",
"muxrpc": "^6.5.1",
"pull-paramap": "^1.2.2",
"pull-stream": "^3.6.14",
Expand Down
19 changes: 18 additions & 1 deletion setup/native-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {Setup} from "web-ext-native-msg"
import path from 'path'
import fs from 'fs'
import fs from 'fs-extra'

const handlerAfterSetup = info => {
const {configDirPath, shellScriptPath, manifestPath} = info;
Expand All @@ -12,6 +12,13 @@ const handlerAfterSetup = info => {
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);
Expand All @@ -32,4 +39,14 @@ const setup = new Setup({
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 })
setup.mainScriptFile = path.resolve(targetPath, './host/host-script.js')
return origCreateShellFunction.apply(setup, [configDir])
}

setup.run();

0 comments on commit 623c4c8

Please sign in to comment.