Skip to content

Commit

Permalink
Merge pull request #10173 from ember-cli/dont-delete-app
Browse files Browse the repository at this point in the history
Don't delete newly-generated app dir on errors
  • Loading branch information
bertdeblock committed Feb 10, 2023
2 parents 7782d25 + 3081e4d commit 690ed75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
16 changes: 2 additions & 14 deletions lib/commands/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const fs = require('fs-extra');
const chalk = require('chalk');
const Command = require('../models/command');
const Project = require('../models/project');
Expand Down Expand Up @@ -115,25 +114,14 @@ module.exports = Command.extend({
project: Project.nullProject(this.ui, this.cli),
});

let opts = await this.runTask('CreateAndStepIntoDirectory', {
await this.runTask('CreateAndStepIntoDirectory', {
projectName,
directoryName: commandOptions.directory,
dryRun: commandOptions.dryRun,
});

initCommand.project.root = process.cwd();

try {
let response = await initCommand.run(commandOptions, rawArgs);
return response;
} catch (err) {
let { initialDirectory, projectDirectory } = opts;

process.chdir(initialDirectory);
await fs.remove(projectDirectory);

console.log(chalk.red(`Error creating new application. Removing generated directory \`./${projectDirectory}\``));
throw err;
}
return await initCommand.run(commandOptions, rawArgs);
},
});
9 changes: 0 additions & 9 deletions tests/acceptance/new-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,6 @@ describe('Acceptance: ember new', function () {
expect(dir('.git')).to.exist;
});

it('ember new cleans up after itself on error', async function () {
fs.mkdirsSync('my_blueprint');
fs.writeFileSync('my_blueprint/index.js', 'throw("this will break");');

await ember(['new', 'foo', '--skip-npm', '--skip-bower', '--skip-git', '--blueprint=./my_blueprint']);

expect(dir('foo')).to.not.exist;
});

it('ember new with --dry-run does not create new directory', async function () {
await ember(['new', 'foo', '--dry-run']);

Expand Down

0 comments on commit 690ed75

Please sign in to comment.