Skip to content

Commit

Permalink
fix: easy zip and easy tar
Browse files Browse the repository at this point in the history
  • Loading branch information
sky committed Nov 26, 2018
1 parent 1ffeb3e commit c48bb21
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
1 change: 0 additions & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ module.exports = class Command {
.action(options => {
this.action.zip(options);
});

}
tar() {
this.program
Expand Down
57 changes: 43 additions & 14 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,29 @@ module.exports = {
return typeof value === 'boolean';
},

getPackageInfo(baseDir) {
const pkgfile = path.join(baseDir || process.cwd(), 'package.json');
if (fs.existsSync(pkgfile)) {
return require(pkgfile);
}
return {};
},

getWebpackInfo(baseDir) {
const configFile = path.join(baseDir || process.cwd(), 'webpack.config.js');
if (fs.existsSync(configFile)) {
return require(configFile);
}
return {};
},

getCompileTempDir(baseDir, dir = '') {
const root = path.join(os.tmpdir(), 'easywebpack');
try {
const pkgfile = path.join(baseDir || process.cwd(), 'package.json');
const pkg = require(pkgfile);
const project = pkg.name;
return path.join(root, project, dir);
} catch (e) {
return root;
const pkg = this.getPackageInfo(baseDir);
if (pkg.name) {
return path.join(root, pkg.name, dir);
}
return root;
},

getInstallPackage(name, baseDir) {
Expand All @@ -48,10 +61,18 @@ module.exports = {
}
},

initArchiveOption(baseDir, program, option) {
const config = {
getDeployOption(baseDir, program) {
const pkg = this.getPackageInfo(baseDir);
const config = this.getWebpackInfo(baseDir);
return merge({}, pkg.deploy, config.deploy);
},

initArchiveOption(baseDir, program, cliOption) {
const configOption = this.getDeployOption(baseDir, program);
const option = merge(configOption, cliOption);
const config = merge(option, {
target: option.target || this.getCompileTempDir(baseDir)
};
});
if(option.filename) {
config.filename = option.filename;
}
Expand All @@ -68,13 +89,21 @@ module.exports = {
}
}
if(option.alinode) {
config.installNode = {
installAlinode: true
let installAlinode = { installAlinode: true };
if (this.isString(option.alinode) && /\.\d/.test(option.alinode)) {
installAlinode.version = option.alinode;
} else if (this.isObject(option.alinode)){
installAlinode = merge(installAlinode, option.alinode);
}
config.installNode = installAlinode;
} else if(option.nodejs) {
config.installNode = {
installNode: true
let installNode = { installNode: true };
if (this.isString(option.nodejs) && /\.\d/.test(option.nodejs)) {
installNode.version = option.nodejs;
} else if (this.isObject(option.nodejs)){
installNode = merge(installNode, option.nodejs);
}
config.installNode = installNode;
}
return config;
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easywebpack-cli",
"version": "4.3.1",
"version": "4.3.2",
"description": "Webpack Building Command Line And Boilerplate Init Tool",
"bin": {
"easywebpack": "bin/cli.js",
Expand Down

0 comments on commit c48bb21

Please # to comment.