-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules/ | |
extension/fimfic2epub.js | ||
extension.crx | ||
extension.pem | ||
extension.xpi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,11 @@ import watch from 'gulp-watch' | |
import lazypipe from 'lazypipe' | ||
import filter from 'gulp-filter' | ||
|
||
import jsonedit from 'gulp-json-editor' | ||
import zip from 'gulp-zip' | ||
|
||
import { execFile } from 'child_process' | ||
|
||
// script | ||
import standard from 'gulp-standard' | ||
import webpack from 'webpack' | ||
|
@@ -95,3 +100,40 @@ gulp.task('default', (done) => { | |
gulp.task('watch', (done) => { | ||
sequence('default', ['watch:lint', 'watch:webpack'], done) | ||
}) | ||
|
||
// creates extensions for chrome and firefox | ||
gulp.task('pack', (done) => { | ||
sequence('default', ['pack:firefox', 'pack:chrome'], done) | ||
}) | ||
|
||
gulp.task('pack:firefox', () => { | ||
let manifest = filter('extension/manifest.json', {restore: true}) | ||
|
||
return gulp.src('extension/**/*') | ||
.pipe(manifest) | ||
.pipe(jsonedit(function (json) { | ||
if (json.content_scripts) { | ||
json.applications = { | ||
gecko: { | ||
id: '[email protected]' | ||
} | ||
} | ||
delete json.background.persistent | ||
} | ||
return json | ||
})) | ||
.pipe(manifest.restore) | ||
.pipe(zip('extension.xpi')) | ||
.pipe(gulp.dest('./')) | ||
}) | ||
|
||
gulp.task('pack:chrome', (done) => { | ||
execFile('./packchrome.sh', [], (error, stdout, stderr) => { | ||
// gutil.log('[pack:chrome]', stdout) | ||
if (error || stderr) { | ||
done(new gutil.PluginError('pack:chrome', stderr, {showStack: false})) | ||
return | ||
} | ||
done() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
#!/bin/bash | ||
|
||
PATH=node_modules/.bin:$PATH | ||
|
||
gulp -p | ||
|
||
CHROME=`command -v chrome || command -v chromium` | ||
|
||
rm -f extension.crx | ||
|
||
code=-1 | ||
|
||
if [ ! -f extension.pem ]; then | ||
echo "Packing chrome extension and generating private key..." | ||
echo "Packaging Chrome extension and generating private key..." | ||
"${CHROME}" --pack-extension=extension | ||
code=$? | ||
else | ||
echo "Packing chrome extension with existing key..." | ||
echo "Packaging Chrome extension with existing key..." | ||
"${CHROME}" --pack-extension=extension --pack-extension-key=extension.pem | ||
code=$? | ||
fi | ||
|
||
if [ ! -f extension.crx ]; then | ||
echo "Something went wrong, Chrome error code ${code}" | ||
>&2 echo "Something went wrong, Chrome error code ${code}" | ||
exit $code | ||
fi | ||
|