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

Commit

Permalink
[fixed] updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
thealjey committed Oct 26, 2015
1 parent d837c96 commit e30aed3
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 57 deletions.
7 changes: 5 additions & 2 deletions build/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var _webpack2 = _interopRequireDefault(_webpack);

var _path = require('path');

var LIVERELOAD_PORT = 35729,
WEB_PORT = 3000;

/**
* A lightweight development server that rapidly recompiles the JavaScript and SASS files when they are edited and
* updates the page.
Expand Down Expand Up @@ -61,7 +64,7 @@ var DevServer = (function () {
function DevServer(script, style, devDir) {
var _this = this;

var port = arguments.length <= 3 || arguments[3] === undefined ? 3000 : arguments[3];
var port = arguments.length <= 3 || arguments[3] === undefined ? WEB_PORT : arguments[3];
var react = arguments.length <= 4 || arguments[4] === undefined ? true : arguments[4];

_classCallCheck(this, DevServer);
Expand Down Expand Up @@ -158,7 +161,7 @@ var DevServer = (function () {
_createClass(DevServer, [{
key: 'watchSASS',
value: function watchSASS(watchDir) {
this.lr.listen(35729);
this.lr.listen(LIVERELOAD_PORT);
this.compileSASS();
(0, _watch2['default'])(watchDir, 'scss', this.compileSASS);
}
Expand Down
5 changes: 3 additions & 2 deletions build/SASSCompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ var _nodeSassImportOnce = require('node-sass-import-once');

var _nodeSassImportOnce2 = _interopRequireDefault(_nodeSassImportOnce);

var options = {
var precision = 8,
options = {
file: null,
outFile: null,
importer: _nodeSassImportOnce2['default'],
importOnce: { index: true, css: false, bower: false },
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets', 'node_modules'],
precision: 8,
precision: precision,
sourceMap: true,
sourceMapContents: true
};
Expand Down
4 changes: 3 additions & 1 deletion build/cssMin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var _cleanCss = require('clean-css');

var _cleanCss2 = _interopRequireDefault(_cleanCss);

var roundingPrecision = -1;

/**
* Minifies CSS
*
Expand All @@ -27,7 +29,7 @@ function cssMin(data) {
var sourceMappingURL = data.code.match(/\n.+$/)[0],
result = new _cleanCss2['default']({
keepSpecialComments: 0,
roundingPrecision: -1,
roundingPrecision: roundingPrecision,
sourceMap: data.map,
sourceMapInlineSources: true
}).minify(data.code);
Expand Down
5 changes: 3 additions & 2 deletions build/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ exports['default'] = watch;

var _fbWatchman = require('fb-watchman');

var client = new _fbWatchman.Client();
var client = new _fbWatchman.Client(),
ALPHANUMERIC_BASE = 36;

/**
* Using the Facebook Watchman, watches the directory "dir" for changes of files with extension "type" and runs
Expand All @@ -26,7 +27,7 @@ var client = new _fbWatchman.Client();
*/

function watch(dir, type, callback) {
var subscription = Number(Date.now()).toString(36);
var subscription = Number(Date.now()).toString(ALPHANUMERIC_BASE);

client.capabilityCheck({}, function (capabilityErr) {
if (capabilityErr) {
Expand Down
2 changes: 2 additions & 0 deletions config/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ rules:
id-length: 0
no-negated-condition: 2
no-mixed-spaces-and-tabs: [ 2, false ]
no-magic-numbers: [ 2, { enforceConst: true, detectObjects: true } ]
no-empty-pattern: 2
7 changes: 5 additions & 2 deletions lib/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import WebpackDevServer from 'webpack-dev-server';
import webpack from 'webpack';
import {join} from 'path';

const LIVERELOAD_PORT = 35729,
WEB_PORT = 3000;

/**
* A lightweight development server that rapidly recompiles the JavaScript and SASS files when they are edited and
* updates the page.
Expand Down Expand Up @@ -41,7 +44,7 @@ export default class DevServer {

server: WebpackDevServer;

constructor(script: string, style: string, devDir: string, port: number = 3000, react: boolean = true) {
constructor(script: string, style: string, devDir: string, port: number = WEB_PORT, react: boolean = true) {
const sass = new SASS(), loaders = [];

if (react) {
Expand Down Expand Up @@ -150,7 +153,7 @@ export default class DevServer {
* server.watchSASS('/path/to/some/directory');
*/
watchSASS(watchDir: string) {
this.lr.listen(35729);
this.lr.listen(LIVERELOAD_PORT);
this.compileSASS();
watch(watchDir, 'scss', this.compileSASS);
}
Expand Down
21 changes: 11 additions & 10 deletions lib/SASSCompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
import {render} from 'node-sass';
import importer from 'node-sass-import-once';

const options = {
file: null,
outFile: null,
importer,
importOnce: {index: true, css: false, bower: false},
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets', 'node_modules'],
precision: 8,
sourceMap: true,
sourceMapContents: true
};
const precision = 8,
options = {
file: null,
outFile: null,
importer,
importOnce: {index: true, css: false, bower: false},
includePaths: ['node_modules/bootstrap-sass/assets/stylesheets', 'node_modules'],
precision,
sourceMap: true,
sourceMapContents: true
};

/**
* SCSS file compiler
Expand Down
4 changes: 3 additions & 1 deletion lib/cssMin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import CleanCSS from 'clean-css';

const roundingPrecision = -1;

/**
* Minifies CSS
*
Expand All @@ -17,7 +19,7 @@ export default function cssMin(data: Object): Object {
const sourceMappingURL = data.code.match(/\n.+$/)[0],
result = new CleanCSS({
keepSpecialComments: 0,
roundingPrecision: -1,
roundingPrecision,
sourceMap: data.map,
sourceMapInlineSources: true
}).minify(data.code);
Expand Down
5 changes: 3 additions & 2 deletions lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import {Client} from 'fb-watchman';

const client = new Client();
const client = new Client(),
ALPHANUMERIC_BASE = 36;

/**
* Using the Facebook Watchman, watches the directory "dir" for changes of files with extension "type" and runs
Expand All @@ -20,7 +21,7 @@ const client = new Client();
* watch(join(__dirname, 'src'), 'js', someFunction);
*/
export default function watch(dir: string, type: string, callback: Function) {
const subscription = Number(Date.now()).toString(36);
const subscription = Number(Date.now()).toString(ALPHANUMERIC_BASE);

client.capabilityCheck({}, function (capabilityErr) {
if (capabilityErr) {
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,39 @@
"homepage": "https://thealjey.github.io/webcompiler",
"dependencies": {
"autoprefixer": "^6.0.3",
"babel": "^5.8.23",
"babel-core": "^5.8.25",
"babel": "^5.8.29",
"babel-core": "^5.8.29",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"babel-runtime": "^5.8.25",
"clean-css": "^3.4.5",
"eslint": "^1.6.0",
"babel-runtime": "^5.8.29",
"clean-css": "^3.4.6",
"eslint": "^1.7.3",
"eslint-config-airbnb": "^0.1.0",
"eslint-plugin-babel": "^2.1.1",
"eslint-plugin-lodash": "^0.1.4",
"eslint-plugin-react": "^3.5.0",
"eslint-plugin-react": "^3.6.3",
"fb-watchman": "^1.6.0",
"mkdirp": "^0.5.1",
"node-sass": "^3.3.3",
"node-sass": "^3.4.0",
"node-sass-import-once": "^1.2.0",
"postcss": "^5.0.9",
"postcss": "^5.0.10",
"tiny-lr": "^0.2.1",
"uglify-js": "^2.5.0",
"webpack": "^1.12.2",
"webpack-dev-server": "^1.12.0"
"webpack-dev-server": "^1.12.1"
},
"peerDependencies": {
"babel-loader": "5.x",
"babel-runtime": "5.x",
"react-hot-loader": "1.x"
},
"devDependencies": {
"babel-istanbul": "^0.3.20",
"babel-istanbul": "^0.4.0",
"coveralls": "^2.11.4",
"jasmine-es6": "^0.0.18",
"jsdoc": "^3.3.3",
"mt-changelog": "^0.6.2",
"proxyquire": "^1.7.3",
"release-script": "^0.5.3"
"release-script": "^0.5.4"
}
}
12 changes: 8 additions & 4 deletions spec/DevServerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import proxyquire from 'proxyquire';

const DEFAULT_WEB_PORT = 3000,
WEB_PORT = 8000,
LIVERELOAD_PORT = 35729;

class SASS {

feDev(inPath: string, outPath: string, callback: Function) {
Expand Down Expand Up @@ -73,14 +77,14 @@ describe('DevServer', function () {
beforeEach(function () {
/* @noflow */
cmp = new DevServer('/path/to/a/script/file.js', '/path/to/a/style/file.scss',
'/path/to/the/development/directory', 8000, false);
'/path/to/the/development/directory', WEB_PORT, false);
});

it('assigns a port number', function () {
if (!cmp) {
return;
}
expect(cmp.port).toBe(8000);
expect(cmp.port).toBe(WEB_PORT);
});

it('constructs a LiveReload server instance', function () {
Expand Down Expand Up @@ -234,7 +238,7 @@ describe('DevServer', function () {
if (!cmp) {
return;
}
expect(cmp.lr.listen).toHaveBeenCalledWith(35729);
expect(cmp.lr.listen).toHaveBeenCalledWith(LIVERELOAD_PORT);
});

it('compiles SASS on start up', function () {
Expand Down Expand Up @@ -269,7 +273,7 @@ describe('DevServer', function () {
if (!cmp) {
return;
}
expect(cmp.server.listen).toHaveBeenCalledWith(3000, '0.0.0.0', jasmine.any(Function));
expect(cmp.server.listen).toHaveBeenCalledWith(DEFAULT_WEB_PORT, '0.0.0.0', jasmine.any(Function));
});

it('prints the error on screen', function () {
Expand Down
13 changes: 9 additions & 4 deletions spec/JSLintSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import JSLint from '../lib/JSLint';
import {CLIEngine} from 'eslint';

const MAX_COMPLEXITY = 4,
props = {complexity: [2, MAX_COMPLEXITY]},
line = 1,
column = 3;

describe('JSLint', function () {
let cmp;

Expand All @@ -13,9 +18,9 @@ describe('JSLint', function () {
});

it('should have easily configurable rules', function () {
cmp = new JSLint({complexity: [2, 4]});
cmp = new JSLint(props);

expect(cmp.linter.options.rules).toEqual(jasmine.objectContaining({complexity: [2, 4]}));
expect(cmp.linter.options.rules).toEqual(jasmine.objectContaining(props));
});

describe('when invoking run', function () {
Expand Down Expand Up @@ -46,12 +51,12 @@ describe('JSLint', function () {
}
spyOn(cmp.linter, 'executeOnFiles').and.returnValue({results: [
{filePath: 'first file', messages: [
{message: 'error message', ruleId: 'some rule', line: 1, column: 3}
{message: 'error message', ruleId: 'some rule', line, column}
]}
]});
cmp.run([], callback);
expect(callback).toHaveBeenCalledWith([
{message: 'error message', ruleId: 'some rule', filePath: 'first file', line: 1, column: 3}
{message: 'error message', ruleId: 'some rule', filePath: 'first file', line, column}
]);
});

Expand Down
24 changes: 15 additions & 9 deletions spec/JSSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ import JSLint from '../lib/JSLint';
import zlib from 'zlib';
import fs from 'fs';

const ERROR_COUNT = 3,
LINE1 = 3,
COLUMN1 = 2,
LINE2 = 12,
COLUMN2 = 5,
MAX_COMPLEXITY = 4,
props = {complexity: [2, MAX_COMPLEXITY]};

describe('JS', function () {
let jsMin;

Expand All @@ -20,7 +28,7 @@ describe('JS', function () {
JS = require('../lib/JS');

/* @noflow */
cmp = new JS({complexity: [2, 4]});
cmp = new JS(props);
});

it('configures Flow', function () {
Expand All @@ -36,9 +44,7 @@ describe('JS', function () {
return;
}
expect(cmp.linter).toEqual(jasmine.any(JSLint));
expect(cmp.linter.linter.options.rules).toEqual(jasmine.objectContaining({
complexity: [2, 4]
}));
expect(cmp.linter.linter.options.rules).toEqual(jasmine.objectContaining(props));
});

});
Expand Down Expand Up @@ -149,8 +155,8 @@ describe('JS', function () {
}
spyOn(cmp.linter, 'run').and.callFake(function (paths, callback) {
callback([
{message: 'error message', ruleId: 'rule id', filePath: 'some file', line: 3, column: 2},
{message: 'error other message', filePath: 'some other file', line: 12, column: 5}
{message: 'error message', ruleId: 'rule id', filePath: 'some file', line: LINE1, column: COLUMN1},
{message: 'error other message', filePath: 'some other file', line: LINE2, column: COLUMN2}
]);
});
cmp.validate('/path/to/a/file.js', ['/lint/this/directory/too'], spy);
Expand All @@ -167,10 +173,10 @@ describe('JS', function () {
it('logs the error to console', function () {
expect(console.log).toHaveBeenCalledWith(
'\x1b[41mESLint error\x1b[0m "\x1b[33m%s%s\x1b[0m" in \x1b[36m%s\x1b[0m on \x1b[35m%s:%s\x1b[0m',
'error message', ' (rule id)', 'some file', 3, 2);
'error message', ' (rule id)', 'some file', LINE1, COLUMN1);
expect(console.log).toHaveBeenCalledWith(
'\x1b[41mESLint error\x1b[0m "\x1b[33m%s%s\x1b[0m" in \x1b[36m%s\x1b[0m on \x1b[35m%s:%s\x1b[0m',
'error other message', '', 'some other file', 12, 5);
'error other message', '', 'some other file', LINE2, COLUMN2);
});

it('does not invoke the callback', function () {
Expand Down Expand Up @@ -249,7 +255,7 @@ describe('JS', function () {
});

it('does not log the successful message', function () {
expect(console.log).toHaveBeenCalledWith('JavaScript compilation errors: %s', 3);
expect(console.log).toHaveBeenCalledWith('JavaScript compilation errors: %s', ERROR_COUNT);
expect(console.log).not.toHaveBeenCalledWith('\x1b[32m%s. Compiled %s\x1b[0m', 1, '/path/to/the/input/file.js');
});

Expand Down
Loading

0 comments on commit e30aed3

Please sign in to comment.