8000 feat(new): add flag to prevent initial git commit (#3712) · andyg3/angular-cli@2e2377d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e2377d

Browse files
Broccohansl
authored andcommitted
feat(new): add flag to prevent initial git commit (angular#3712)
1 parent 8b1c039 commit 2e2377d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/angular-cli/commands/init.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const InitCommand: any = Command.extend({
2020
{ name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
2121
{ name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
2222
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
23+
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
24+
{ name: 'skip-commit', type: Boolean, default: false, aliases: ['sc'] },
2325
{ name: 'name', type: String, default: '', aliases: ['n'] },
2426
{ name: 'source-dir', type: String, default: 'src', aliases: ['sd'] },
2527
{ name: 'style', type: String, default: 'css' },

packages/angular-cli/commands/new.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const NewCommand = Command.extend({
1919
{ name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
2020
{ name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
2121
{ name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
22+
{ name: 'skip-commit', type: Boolean, default: false, aliases: ['sc'] },
2223
{ name: 'directory', type: String, aliases: ['dir'] },
2324
{ name: 'source-dir', type: String, default: 'src', aliases: ['sd'] },
2425
{ name: 'style', type: String, default: 'css' },

packages/angular-cli/tasks/git-init.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,23 @@ module.exports = Task.extend({
3838
.catch(function() {
3939
return false;
4040
})
41-
})
41+
})
4242
.then(function (insideGitRepo) {
4343
if (insideGitRepo) {
4444
return ui.writeLine('Directory is already under version control. Skipping initialization of git.');
45-
}
45+
}
4646
return exec('git init')
4747
.then(function () {
4848
return exec('git add .');
4949
})
5050
.then(function () {
51-
var commitTemplate = fs.readFileSync(
52-
path.join(__dirname, '../utilities/INITIAL_COMMIT_MESSAGE.txt'));
53-
var commitMessage = template(commitTemplate)(pkg);
54-
return exec(
55-
'git commit -m "' + commitMessage + '"', { env: gitEnvironmentVariables });
51+
if (!commandOptions.skipCommit) {
52+
var commitTemplate = fs.readFileSync(
53+
path.join(__dirname, '../utilities/INITIAL_COMMIT_MESSAGE.txt'));
54+
var commitMessage = template(commitTemplate)(pkg);
55+
return exec(
56+
'git commit -m "' + commitMessage + '"', { env: gitEnvironmentVariables });
57+
}
5658
})
5759
.then(function () {
5860
ui.writeLine(chalk.green('Successfully initialized git.'));

0 commit comments

Comments
 (0)
0