AvianFlu / ncp

Asynchronous recursive file copying with Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async Callback Buggy

DavidSouther opened this issue · comments

Starting with grunt-docco, we noticed a directory copy sometimes failed (DavidSouther/grunt-docco#40). We tracked that down to node-fs-extra, where @malinges opened jprichardson/node-fs-extra#98; I duplicated that error using ncp directly and am opening this here.

% git clone https://gist.github.com/DavidSouther/77db8d2ce83c98521082
% cd 77db8d2ce83c98521082
% npm install
% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }
done: { '0': null }

% node copytest1.js
done: { '0': null }
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }

% node copytest1.js
done: { '0': null }
done: { '0': null }

% node copytest2.js
done: { '0': null }

% node copytest2.js

% node copytest2.js

% node copytest2.js

% node copytest2.js

%

We expect either of these files to always output exactly one done event with no arguments.

Possibly related to #51, #66?

👍

This only occurs when the target directory is not empty.

There's a fix for this in jprichardson/node-fs-extra#98 (comment) at jprichardson/node-fs-extra@35345a3 - but lack of dev interest on the issues board is frustrating.