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

compileAllJsFilesInDir: Added promise #1552

Closed
wants to merge 6 commits into from

Conversation

tuchk4
Copy link
Contributor

@tuchk4 tuchk4 commented Dec 2, 2014

If I should execute other scripts after traceur compilation I need to know when compilation is finished.
But seems in this PR one problem - on reject way.

errback at .compileSingleFile - only if there are problems in file reading. Parse errors are thrown in other scope.

return new Promise(function(resolve, reject) {
glob(inputDir + '/**/*.js', {}, function (er, files) {
if (er)
throw new Error('While scanning ' + inputDir + ': ' + er);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should then be:

if (err) {
  reject(new Error('While scanning ' + inputDir + ': ' + err));
  return;
}

But we also need to terminate the glob.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think test should be added for this function. Especially for reject.

@googlebot
Copy link
Collaborator

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

var outputFilePath = inputFilePath.replace(inputDir, outputDir);
var compiler = new NodeCompiler(options);
compiler.compileSingleFile(inputFilePath, outputFilePath, function (err) {
throw new Error('While reading ' + inputFilePath + ': ' + err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

@arv
Copy link
Collaborator

arv commented Dec 3, 2014

@tuchk4 I manually checked that you signed the CLA for the other PR. Maybe your information did not include the GitHub user name?

 - wrap throw with reject.
 - CS
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@tuchk4
Copy link
Contributor Author

tuchk4 commented Dec 3, 2014

@arv GH name already added. CLAs look good

@arv arv added the cla: yes label Dec 3, 2014
}

var total = files.length,
current = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var for both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not 0? You can drop else with it:

var total = files.length;
var current = 0;

current++;
if (current === total) {
  resolve();
}

@johnjbarton
Copy link
Contributor

Can you add two tests that calls this function, one success and one failure? The test also serves as an example.

@arv arv closed this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants