-
Notifications
You must be signed in to change notification settings - Fork 118
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
2b79310
commit 613be94
Showing
3 changed files
with
70 additions
and
9 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 |
---|---|---|
|
@@ -6,3 +6,6 @@ | |
node_modules | ||
yarn.lock | ||
package-lock.json | ||
|
||
# Release | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const fs = require('fs') | ||
const fse = require('fs-extra') | ||
const path = require('path') | ||
const archiver = require('archiver') | ||
|
||
const VERSION = require(path.resolve(__dirname, '../package.json')).version.split('.').slice(0, 2).join('.') | ||
const DIST_DIR = path.resolve(__dirname, `../dist`) | ||
const DIST_FILE = path.resolve(DIST_DIR, `Shuang_${VERSION}.zip`) | ||
|
||
const FILE_LIST = [ | ||
'img', | ||
'build', | ||
'README.md', | ||
'LICENSE', | ||
'index.html', | ||
] | ||
|
||
console.log(`creating release dist for ${VERSION}`) | ||
|
||
fse.mkdirpSync(DIST_DIR) | ||
try { | ||
fse.rmSync(DIST_FILE) | ||
} catch (e) {} | ||
|
||
const output = fs.createWriteStream(DIST_FILE) | ||
const zip = archiver('zip') | ||
|
||
output.on('close', function () { | ||
console.log(`=> ${DIST_FILE} (${Math.ceil(zip.pointer() / 1024)} kb)`) | ||
}) | ||
|
||
zip.on('error', function (err) { | ||
throw err | ||
}) | ||
|
||
zip.pipe(output) | ||
|
||
for (const filename of FILE_LIST) { | ||
const filepath = path.resolve(__dirname, `../${filename}`) | ||
if (!fs.existsSync(filepath)) { | ||
console.error(`? ${filename}`) | ||
} | ||
try { | ||
if (fs.lstatSync(filepath).isDirectory()) { | ||
zip.directory(filepath,filename) | ||
console.log(`+ ${filename}/*`) | ||
} else { | ||
zip.file(filepath, { name: filename }) | ||
console.log(`+ ${filename}`) | ||
} | ||
} catch (e) { | ||
throw e | ||
} | ||
} | ||
|
||
zip.finalize() |