Commit e3b3b8e3 authored by wildfirecode's avatar wildfirecode

1

parent 71a3d835
...@@ -13,6 +13,8 @@ const OSS = require('ali-oss'); ...@@ -13,6 +13,8 @@ const OSS = require('ali-oss');
const chalk = require('chalk'); const chalk = require('chalk');
const ProgressBar = require('progress'); const ProgressBar = require('progress');
const BUILD_TYPE_argv = process.argv[2];
const BUILD_TYPE = BUILD_TYPE_argv.split('=')[1];
class TuiaAutoUpload { class TuiaAutoUpload {
constructor(props) { constructor(props) {
const defaultOptions = { const defaultOptions = {
...@@ -32,7 +34,7 @@ class TuiaAutoUpload { ...@@ -32,7 +34,7 @@ class TuiaAutoUpload {
region: 'oss-cn-hangzhou', region: 'oss-cn-hangzhou',
accessKeyId: 'LTAIdGi1IOap7fkF', accessKeyId: 'LTAIdGi1IOap7fkF',
accessKeySecret: 'SKrOOp6EVtDGEV47yn0t2h97gyNioQ', accessKeySecret: 'SKrOOp6EVtDGEV47yn0t2h97gyNioQ',
bucket: process.env.BUILD_TYPE === 'production' ? 'duiba' : 'daily-duiba' bucket: BUILD_TYPE === 'production' ? 'duiba' : 'daily-duiba'
}); });
this.bar = new ProgressBar(chalk.yellow(` 文件上传中 [:bar] :current/${this.files().length} :percent :elapseds`), { this.bar = new ProgressBar(chalk.yellow(` 文件上传中 [:bar] :current/${this.files().length} :percent :elapseds`), {
complete: '●', complete: '●',
...@@ -67,14 +69,14 @@ class TuiaAutoUpload { ...@@ -67,14 +69,14 @@ class TuiaAutoUpload {
} catch (error) { } catch (error) {
originFile = error; originFile = error;
} }
if (process.env.BUILD_TYPE === 'production') { if (BUILD_TYPE === 'production') {
if (originFile.status === 404) { if (originFile.status === 404) {
yield _this.client.put(originPath, path); yield _this.client.put(originPath, path);
_this.uploadFiles += 1; _this.uploadFiles += 1;
} else { } else {
_this.existFiles += 1; _this.existFiles += 1;
} }
} else if (process.env.BUILD_TYPE === 'development') { } else if (BUILD_TYPE === 'development') {
if (originFile.status === 404 || originFile.status === 200) { if (originFile.status === 404 || originFile.status === 200) {
_this.existFiles += 1; _this.existFiles += 1;
} }
......
{ {
"name": "tuia-auto-upload", "name": "tuia-auto-upload",
"version": "1.1.1", "version": "1.1.3",
"description": "推啊系统后台自动上传工具", "description": "推啊系统后台自动上传工具",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@gitlab2.dui88.com:frontend/autoupload.git" "url": "git@gitlab2.dui88.com:wanghongyuan/duiba-autoupload.git"
}, },
"author": "zc@duiba.com.cn", "author": "zc@duiba.com.cn",
"license": "ISC", "license": "ISC",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment