Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lint

  • Loading branch information...
commit 01c07206a144b89938a7589aca6d6ae50d075983 1 parent c33a714
@cjohansen cjohansen authored
View
20 lib/fs-filtered.js
@@ -37,26 +37,26 @@ function exclude(patterns) {
};
}
-function include(patterns) {
- return function (file) {
- return patterns.some(function (pattern) {
- return file.isDirectory() || prepareFileNameForComparison(file.name).match(pattern);
- });
- };
-}
-
function prepareFileNameForComparison(fileName) {
-
var platform = typeof process === "object" ? process.platform : "win32";
// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
if (platform === "win32") {
- fileName = fileName.split("\\").join("/")
+ fileName = fileName.split("\\").join("/");
}
return fileName;
}
+function include(patterns) {
+ return function (file) {
+ return patterns.some(function (pattern) {
+ return file.isDirectory() ||
+ prepareFileNameForComparison(file.name).match(pattern);
+ });
+ };
+}
+
function statFiles(dir, callback) {
var excludes = this.excludes || [];
var includes = this.includes || [];
View
3  lib/fs-watcher.js
@@ -46,7 +46,8 @@ module.exports = {
if (exists) {
throw error;
} else {
- console.log("Watching error occurred for non existing file: " + file.name + " (" + error + ")");
+ console.log("Watching error occurred for non existing " +
+ "file: " + file.name + " (" + error + ")");
}
});
});
View
20 test/fs-watcher-test.js
@@ -53,14 +53,14 @@ buster.testCase('fs-watcher', {
assert.calledTwice(this.closer.close);
},
-
+
"register error handler for closer": function () {
this.watcher.watch({ name: "files" }, this.spy());
-
+
assert.calledWith(this.closer.on, "error");
},
-
+
"ignore error if directory doesn't exist": function () {
this.stub(fs, "exists", function (fileName, callback) {
@@ -72,26 +72,28 @@ buster.testCase('fs-watcher', {
this.closer.on = function (event, callback) {
if (event === "error") {
refute.exception(callback.bind(null, error));
- assert.calledWith(console.log, "Watching error occurred for non existing file: notExist (Error: permission)");
+ assert.calledWith(console.log, "Watching error occurred for " +
+ "non existing file: notExist (Error: " +
+ "permission)");
}
};
-
+
this.watcher.watch({ name: "notExist" }, this.spy());
},
-
+
"forward error if directory exist": function () {
-
+
this.stub(fs, "exists", function (fileName, callback) {
callback(true);
});
var error = new Error("error");
-
+
this.closer.on = function (event, callback) {
if (event === "error") {
assert.exception(callback.bind(null, error), "Error", "error");
}
};
-
+
this.watcher.watch({ name: "files" }, this.spy());
}
View
5 test/helper.js
@@ -2,6 +2,7 @@ var when = require("when");
var path = require("path");
var fs = require("fs");
+// Please jslint...
var mknode;
function mktree(tree, root) {
@@ -18,7 +19,7 @@ function mktree(tree, root) {
return when.all(promises);
}
-mknode = function (tree, prop, file, callback) {
+function mknode(tree, prop, file, callback) {
if (typeof tree[prop] === "object") {
fs.mkdir(file, "0755", function () {
mktree(tree[prop], file).then(callback);
@@ -26,7 +27,7 @@ mknode = function (tree, prop, file, callback) {
} else {
fs.writeFile(file, tree[prop], "utf-8", callback);
}
-};
+}
module.exports = {
ROOT: path.join(__dirname, ".#fixtures"),
View
9 test/os-watch-helper.js
@@ -51,7 +51,10 @@ function watch(file, callback) {
callback: callback
};
this.watchers.push(watcher);
- return { close: removeWatcher.bind(this, watcher), on: function() {} };
+ return {
+ close: removeWatcher.bind(this, watcher),
+ on: function () {}
+ };
}
function event(file, e, info) {
@@ -210,8 +213,8 @@ module.exports = {
return instance;
},
- get watchers() { return this.os.watchers; },
- set watchers(value) { throw new Error("Property is not writable"); },
+ get watchers () { return this.os.watchers; },
+ set watchers (value) { throw new Error("Property is not writable"); },
change: function (file) {
var d = when.defer(), os = this.os;
View
5 test/watch-tree-unix-test.js
@@ -63,11 +63,10 @@ function eventTest(options) {
}
buster.testCase("watch-tree-unix", {
-
requiresSupportFor: {
- "*nix": process.platform != "win32"
+ "*nix": process.platform !== "win32"
},
-
+
setUp: function () {
fs.mkdirSync(helper.ROOT, "0755");
Please sign in to comment.
Something went wrong with that request. Please try again.