Permalink
Browse files

throw exception if mix.js() was not called

  • Loading branch information...
DarkaOnLine committed Jan 13, 2017
1 parent c0b255e commit 4e78e374f9220166c907931982cc92379c538fee
Showing with 16 additions and 1 deletion.
  1. +7 −0 src/Mix.js
  2. +9 −1 test/mix.js
View
@@ -64,6 +64,13 @@ class Mix {
entry() {
// We'll build up an entry object that the webpack.config.js
// file will want to see. It'll include all mix.js() calls.
if (!this.js) {
throw new Error(
`Laravel Mix: You must call "mix.js()" once or more.`
);
}
let entry = this.js.reduce((result, paths) => {
result[paths.output.name] = paths.entry.map(src => src.path);
View
@@ -1,11 +1,19 @@
import test from 'ava';
import mix from '../src/index';
import {mix, config as Mix} from '../src/index';
import path from 'path';
test.afterEach('cleanup', t => {
mix.reset();
});
test('that it throws exception if mix.js() was not called', t => {
const error = t.throws(() => {
mix.sass('sass/stub.scss', 'dist');
Mix.entry();
}, Error);
t.is(error.message, 'Laravel Mix: You must call "mix.js()" once or more.');
});
test('that it determines the JS paths', t => {
mix.js('js/stub.js', 'dist')

0 comments on commit 4e78e37

Please sign in to comment.