Skip to content

Commit

Permalink
support ignore with config files (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored and sorrycc committed May 22, 2019
1 parent 6463e6a commit 385c008
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ if (!semver.satisfies(process.version, '>= 8.0.0')) {
const name = args._[0] || '';
run({
name,
args,
});
24 changes: 22 additions & 2 deletions lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
const path = require('path');
const chalk = require('chalk');
const del = require('del');
const BasicGenerator = require('../../BasicGenerator');

class AntDesignProGenerator extends BasicGenerator {
async writing() {
const path = this.opts.name || './';
const gitArgs = [`clone`, `https://github.com/umijs/ant-design-pro`, `--depth=1`, path];
const projectName = this.opts.name || './';
const gitArgs = [ `clone`, `https://github.com/ant-design/ant-design-pro`, `--depth=1` ];

// Set branch if provided
if (this.opts.args.branch) {
gitArgs.push('--branch', this.opts.args.branch);
}

gitArgs.push(projectName);

console.log(`${chalk.gray('>')} git ${gitArgs.join(' ')}`);
await require('execa')(`git`, gitArgs);

const projectPath = path.resolve(projectName);
const packageJsonPath = path.resolve(projectPath, 'package.json');
const pkg = require(packageJsonPath);

if (pkg['create-umi'] && pkg['create-umi'].ignore) {
console.log(`${chalk.gray('>')} clean up...`);
const ignoreFiles = pkg['create-umi'].ignore;
del.sync(ignoreFiles, { cwd: projectPath });
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const generators = fs
};
});

const runGenerator = async (generatorPath, { name = '', cwd = process.cwd() }) => {
const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), args = {} }) => {
return new Promise(resolve => {
if (name) {
mkdirp.sync(name);
Expand All @@ -30,6 +30,7 @@ const runGenerator = async (generatorPath, { name = '', cwd = process.cwd() }) =
cwd,
},
resolved: require.resolve(generatorPath),
args,
});

return generator.run(() => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"chalk": "^2.4.1",
"clipboardy": "^1.2.3",
"debug": "^3.1.0",
"del": "^4.1.1",
"execa": "^1.0.0",
"inquirer": "^6.2.1",
"mkdirp": "^0.5.1",
Expand Down

0 comments on commit 385c008

Please sign in to comment.