forked from webclipper/web-clipper
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a14263f
commit f9b5da1
Showing
4 changed files
with
64 additions
and
2 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 |
---|---|---|
|
@@ -12,3 +12,4 @@ dll/ | |
webclipper.zip | ||
|
||
.now | ||
release |
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,4 +1,18 @@ | ||
const webpack = require('webpack'); | ||
const prodConfig = require('../webpack/webpack.prod'); | ||
const compiler = webpack(prodConfig); | ||
compiler.run(); | ||
|
||
function send(data) { | ||
if (!process.send) { | ||
return; | ||
} | ||
return new Promise(r => { | ||
process.send(data, null, {}, r); | ||
}); | ||
} | ||
|
||
compiler.run(() => { | ||
send({ | ||
type: 'Success', | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { fork } = require('child_process'); | ||
const path = require('path'); | ||
const compressing = require('compressing'); | ||
const fs = require('fs'); | ||
const pump = require('pump'); | ||
|
||
const releaseDir = path.join(__dirname, '../release'); | ||
if (!fs.existsSync(releaseDir)) { | ||
fs.mkdirSync(releaseDir); | ||
} | ||
|
||
function build(targetBrowser) { | ||
const buildScript = require.resolve('./build'); | ||
const buildEnv = Object.create(process.env); | ||
buildEnv.NODE_ENV = 'production'; | ||
buildEnv.TARGET_BROWSER = targetBrowser; | ||
const cp = fork(buildScript, [], { | ||
env: buildEnv, | ||
silent: true, | ||
}); | ||
return new Promise(r => { | ||
cp.on('message', r); | ||
}); | ||
} | ||
function pack(targetBrowser) { | ||
const dist = path.resolve(__dirname, `../dist`); | ||
const { version } = JSON.parse(fs.readFileSync(path.join(dist, 'manifest.json'), 'utf-8')); | ||
const zipStream = new compressing.zip.Stream(); | ||
fs.readdirSync(dist).forEach(o => { | ||
if (o.match(/^\./)) { | ||
return; | ||
} | ||
zipStream.addEntry(path.join(dist, o)); | ||
}); | ||
const dest = path.join(releaseDir, `web_clipper_${version}_${targetBrowser}.zip`); | ||
const destStream = fs.createWriteStream(dest); | ||
return new Promise(r => { | ||
pump(zipStream, destStream, r); | ||
}); | ||
} | ||
|
||
(async () => { | ||
const browserList = ['Firefox', 'Chrome']; | ||
for (const browser of browserList) { | ||
await build(browser); | ||
await pack(browser); | ||
} | ||
})(); |
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