-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 changed file
with
23 additions
and
8 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 |
---|---|---|
@@ -1,17 +1,32 @@ | ||
/* eslint no-console: 0 */ | ||
|
||
const path = require('path') | ||
const cp = require('child_process') | ||
const chalk = require('chalk') | ||
const timestamp = require('tinydate')('{YYYY}/{MM}/{DD} {HH}:{mm}:{ss}') | ||
const manifest = require('../static/manifest') | ||
|
||
function zip() { | ||
function log(message) { | ||
console.log(`[${chalk.cyan(timestamp())}] ${message}`) | ||
} | ||
|
||
function pack() { | ||
const version = manifest.version_name || manifest.version | ||
const zipName = `space-fanfou-${version}.zip` | ||
const outPath = path.join(__dirname, '..', zipName) | ||
const distPath = path.join(__dirname, '..', 'dist') | ||
const command = `rm -f ${outPath} && cd ${distPath} && zip -r ${outPath} ./*` | ||
const pkgRootPath = path.join(__dirname, '..') | ||
const outPath = path.join(pkgRootPath, zipName) | ||
const distPath = path.join(pkgRootPath, 'dist') | ||
const command = `rm -f ${JSON.stringify(outPath)} && cd ${JSON.stringify(distPath)} && zip -r ${JSON.stringify(outPath)} *` | ||
|
||
log(`正在创建:${chalk.green(zipName)}`) | ||
|
||
cp.execSync(command) | ||
// eslint-disable-next-line no-console | ||
console.log(`创建成功:${chalk.green(zipName)}`) | ||
cp.exec(command, error => { | ||
if (error) { | ||
log(chalk.red('创建失败')) | ||
console.log(error) | ||
} else { | ||
log(chalk.green('创建成功')) | ||
} | ||
}) | ||
} | ||
zip() | ||
pack() |