Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding failing tests for end event firing multiple times when copying a file more than once. #402

Merged
merged 1 commit into from
Nov 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function prepCopy(source, destination, process) {
actions.copy = function copy(source, destination, process) {

var file = prepCopy.call(this, source, destination, process);

try {
file.body = this.engine(file.body, this);
} catch (err) {
Expand Down Expand Up @@ -290,7 +290,9 @@ actions.checkForCollision = function checkForCollision(filepath, content, cb) {
content: content
});

this.conflicter.once('resolved:' + filepath, cb.bind(this, null));
this.conflicter.once('resolved:' + filepath, function (config) {
process.nextTick(cb.bind(this, null, config));
}.bind(this));
};

/**
Expand Down
32 changes: 32 additions & 0 deletions test/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,38 @@ describe('Environment', function () {
// actual run
.run('angular:all myapp');
});

it('only call the end event once (bug #402)', function (done) {
function GeneratorOnce() {
generators.Base.apply(this, arguments);
this.sourceRoot(path.join(__dirname, 'fixtures'));
this.destinationRoot(path.join(__dirname, 'temp'));
}

util.inherits(GeneratorOnce, generators.Base);

GeneratorOnce.prototype.createDuplicate = function () {
this.copy('foo-copy.js');
this.copy('foo-copy.js');
};

var generatorOnce = new GeneratorOnce([], {
env: generators(),
resolved: __filename
});

var isFirstEndEvent = true;

generatorOnce.on('end', function () {
assert.ok(isFirstEndEvent);
if (isFirstEndEvent) {
done();
}
isFirstEndEvent = false;
});

generatorOnce.run();
});
});

describe('Store', function() {
Expand Down