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

Fix for wrong separator in entry #7

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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 lib/index.js
Expand Up @@ -43,7 +43,11 @@ module.exports = options => (files, metalsmith, done) => {
}

const source = metalsmith.source();
const promises = options.entries.map(entry => bundle({ entry, options, source, files }));

const needToFixEntry = path.sep !== '/';
const promises = options.entries
.map(entry => (needToFixEntry ? entry.replace(/\//g, path.sep) : entry))
.map(entry => bundle({ entry, options, source, files }));

Promise.all(promises)
.then(() => done())
Expand Down
14 changes: 14 additions & 0 deletions lib/index.test.js
Expand Up @@ -60,6 +60,20 @@ describe('metalsmith-browserify', () => {
});
});

it('should fix separator in entries', done => {
const base = path.join(process.cwd(), 'test', 'fixtures', 'fix-entry-separator');
const metalsmith = new Metalsmith(base);

return metalsmith
.use(plugin({ entries: ['js/index.js'], browserifyOptions: { debug: true } }))
.build(err => {
if (err) {
return done(err);
}
return done();
});
});

it('should return an error when there is an error while bundling', done => {
const base = path.join(process.cwd(), 'test', 'fixtures', 'bundle-error');
const metalsmith = new Metalsmith(base);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/fix-entry-separator/src/js/index.js
@@ -0,0 +1 @@
console.log('something');