Skip to content

Commit

Permalink
package.json: Add chrome-open script (OctoLinker#247)
Browse files Browse the repository at this point in the history
Like the `firefox-open` script, this builds and loads the extension into
an isolated instance of Chrome, using [chrome-launch]. This has a couple
of benefits:

1. New developers can get up-and-running faster
2. It's easier to test Chrome without any other user settings

One caveat so far is that Chrome opens in the background rather than the
foreground, but this is alleviated by printing a message out informing
the developer.

[chrome-launch]: https://github.com/hughsk/chrome-launch
  • Loading branch information
josephfrazier authored and stefanbuck committed Jan 11, 2017
1 parent 78c5877 commit 4c78d4a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ To build and run the extension follow these steps.
* [Python]
* [project.json]
0. Build and load the extension:
* Chrome:
* Firefox (Quickstart):
0. `npm run firefox-open`
* Chrome (Quickstart):
0. `npm run chrome-open`
* Chrome (Long Version):
0. To build the extension once run `npm run chrome-build` or `npm run chrome-watch` during development.
0. Load extension https://developer.chrome.com/extensions/getstarted#unpacked.
* Firefox:
0. `npm run firefox-open`

[Docker]: https://github.com/OctoLinker/browser-extension/commit/33a2e60
[vimrc]: https://github.com/OctoLinker/browser-extension/commit/7e21743
Expand Down
42 changes: 42 additions & 0 deletions npm-shrinkwrap.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"chrome-dist": "npm run chrome-build -- -p",
"chrome-watch": "npm run chrome-manifest && webpack --watch",
"chrome-pack": "npm run chrome-dist && mkdirp out && zip -rj out/chrome-octolinker-$npm_package_version.zip dist",
"chrome-open": "npm run chrome-build && ./scripts/chrome-launch.js",
"firefox-manifest": "mkdirp dist && cp assets/manifest.json dist/manifest.json",
"firefox-build": "npm run firefox-manifest && webpack",
"firefox-dist": "npm run firefox-build -- -p",
Expand Down Expand Up @@ -48,6 +49,7 @@
"babel-loader": "6.2.10",
"babel-plugin-transform-object-rest-spread": "6.20.2",
"babel-preset-es2015": "6.18.0",
"chrome-launch": "1.1.4",
"chrome-webstore-upload-cli": "1.1.0",
"copy-webpack-plugin": "4.0.1",
"eslint": "3.12.2",
Expand Down
9 changes: 9 additions & 0 deletions scripts/chrome-launch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

const chromeLaunch = require('chrome-launch'); // eslint-disable-line import/no-extraneous-dependencies

const url = 'https://github.com/OctoLinker/browser-extension/blob/master/package.json';
const args = ['--load-extension=./dist'];

chromeLaunch(url, { args });
console.log('A new instance of Chrome should now be open in the background.'); // eslint-disable-line no-console

0 comments on commit 4c78d4a

Please sign in to comment.