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

catch css file not found #2206

Merged
merged 4 commits into from Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/core/parcel-bundler/src/assets/RawAsset.js
Expand Up @@ -27,7 +27,11 @@ class RawAsset extends Asset {
}

async generateHash() {
return await md5.file(this.name);
try {
return await md5.file(this.name);
} catch (err) {
throw new Error(err);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to catch and re-throw the error here? Isn't that the same as just not catching it in the first place?

}
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/core/parcel-bundler/src/utils/md5.js
Expand Up @@ -11,11 +11,13 @@ function md5(string, encoding = 'hex') {
md5.file = function(filename) {
return new Promise((resolve, reject) => {
fs.createReadStream(filename)
.on('error', function(error) {
reject(error);
Copy link
Member

Choose a reason for hiding this comment

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

I think you can write this like before by just passing reject directly as the callback instead of making a wrapper function

})
.pipe(crypto.createHash('md5').setEncoding('hex'))
.on('finish', function() {
resolve(this.read());
})
.on('error', reject);
});
});
};

Expand Down