Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
thealjey committed Feb 14, 2017
1 parent 50b24dd commit f863795
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/JSCompiler.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1 class="page-title">JSCompiler.js</h1>
import forEach from 'lodash/forEach';
import noop from 'lodash/noop';
import {getCompiler} from './webpack';
import {babelBEOptions} from './util';
import {babelBEOptions, isProduction} from './util';
import {logError, log, consoleStyles} from './logger';

/* eslint-disable no-sync */
Expand Down Expand Up @@ -237,7 +237,7 @@ <h1 class="page-title">JSCompiler.js</h1>
}
this.save(inPath, outPath, {
code: compiler.outputFileSystem.readFileSync(outPath, 'utf8'),
map: compiler.outputFileSystem.readFileSync(`${outPath}.map`, 'utf8')
map: isProduction ? compiler.outputFileSystem.readFileSync(`${outPath}.map`, 'utf8') : ''
}, callback);
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/JSCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class JSCompiler extends _Compiler.Compiler {
}
this.save(inPath, outPath, {
code: compiler.outputFileSystem.readFileSync(outPath, 'utf8'),
map: compiler.outputFileSystem.readFileSync(`${outPath}.map`, 'utf8')
map: _util.isProduction ? compiler.outputFileSystem.readFileSync(`${outPath}.map`, 'utf8') : ''
}, callback);
});
}
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@
"homepage": "https://thealjey.github.io/webcompiler",
"dependencies": {
"autoprefixer": "^6.7.2",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-es2015-modules-commonjs": "^6.22.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-loader": "^6.3.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.23.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-es2017": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.22.0",
"babel-runtime": "^6.22.0",
"babel-runtime": "^6.23.0",
"cheerio": "^0.22.0",
"clean-stack": "^1.1.1",
"codemirror": "^5.23.0",
Expand All @@ -100,7 +100,7 @@
"node-sass": "^4.5.0",
"node-sass-import-once": "^1.2.0",
"null-loader": "^0.1.1",
"postcss": "^5.2.12",
"postcss": "^5.2.13",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-hot-loader": "^1.3.1",
Expand Down
29 changes: 21 additions & 8 deletions test/JSCompiler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,24 @@ describe('JSCompiler', () => {
beforeEach(() => {
run = stub().callsArgWith(0, null, {toJson: () => ({errors: [], warnings: []})});
readFileSync = stub().returnsArg(0);
JSCompiler = req({'./webpack': {getCompiler: () => ({run, outputFileSystem: {readFileSync}})}});
cmp = new JSCompiler();
stub(cmp, 'save');
});

afterEach(() => {
cmp.save.restore();
});

describe('no callback', () => {

beforeEach(() => {
JSCompiler = req({
'./webpack': {getCompiler: () => ({run, outputFileSystem: {readFileSync}})},
'./util': {isProduction: true}
});
cmp = new JSCompiler();
stub(cmp, 'save');
cmp.fe('/path/to/the/input/file.js', '/path/to/the/output/file.js');
});

afterEach(() => {
cmp.save.restore();
});

it('calls save', () => {
expect(cmp.save).calledWith('/path/to/the/input/file.js', '/path/to/the/output/file.js',
{code: '/path/to/the/output/file.js', map: '/path/to/the/output/file.js.map'}, match.func);
Expand All @@ -131,12 +134,22 @@ describe('JSCompiler', () => {
describe('callback', () => {

beforeEach(() => {
JSCompiler = req({
'./webpack': {getCompiler: () => ({run, outputFileSystem: {readFileSync}})},
'./util': {isProduction: false}
});
cmp = new JSCompiler();
stub(cmp, 'save');
cmp.fe('/path/to/the/input/file.js', '/path/to/the/output/file.js', callback);
});

afterEach(() => {
cmp.save.restore();
});

it('calls save', () => {
expect(cmp.save).calledWith('/path/to/the/input/file.js', '/path/to/the/output/file.js',
{code: '/path/to/the/output/file.js', map: '/path/to/the/output/file.js.map'}, callback);
{code: '/path/to/the/output/file.js', map: ''}, callback);
});

});
Expand Down

0 comments on commit f863795

Please sign in to comment.