Skip to content

Commit

Permalink
ESLint auto-fixes (replaced single quotes with double quotes)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMessinger committed Dec 13, 2018
1 parent b6266c5 commit 74767c6
Show file tree
Hide file tree
Showing 25 changed files with 857 additions and 856 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ root = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

# 2 space indentation
indent_style = space
indent_size = 2

# JavaScript-specific settings
[*.js]
quote_type = single
quote_type = double
continuation_indent_size = 2
curly_bracket_next_line = false
indent_brace_style = BSD
Expand Down
2 changes: 1 addition & 1 deletion lib/async/for-each.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

module.exports = asyncForEach;

Expand Down
18 changes: 9 additions & 9 deletions lib/async/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
"use strict";

module.exports = readdirAsync;

const maybe = require('call-me-maybe');
const DirectoryReader = require('../directory-reader');
const maybe = require("call-me-maybe");
const DirectoryReader = require("../directory-reader");

let asyncFacade = {
fs: require('fs'),
forEach: require('./for-each'),
fs: require("fs"),
forEach: require("./for-each"),
};

/**
Expand All @@ -20,7 +20,7 @@ let asyncFacade = {
* @param {object} internalOptions
*/
function readdirAsync (dir, options, callback, internalOptions) {
if (typeof options === 'function') {
if (typeof options === "function") {
callback = options;
options = undefined;
}
Expand All @@ -33,14 +33,14 @@ function readdirAsync (dir, options, callback, internalOptions) {
let reader = new DirectoryReader(dir, options, internalOptions);
let stream = reader.stream;

stream.on('error', err => {
stream.on("error", err => {
reject(err);
stream.pause();
});
stream.on('data', result => {
stream.on("data", result => {
results.push(result);
});
stream.on('end', () => {
stream.on("end", () => {
resolve(results);
});
})));
Expand Down
2 changes: 1 addition & 1 deletion lib/call.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

let call = module.exports = {
safe: safeCall,
Expand Down
46 changes: 23 additions & 23 deletions lib/directory-reader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
"use strict";

const Readable = require('stream').Readable;
const EventEmitter = require('events').EventEmitter;
const path = require('path');
const normalizeOptions = require('./normalize-options');
const stat = require('./stat');
const call = require('./call');
const Readable = require("stream").Readable;
const EventEmitter = require("events").EventEmitter;
const path = require("path");
const normalizeOptions = require("./normalize-options");
const stat = require("./stat");
const call = require("./call");

/**
* Asynchronously reads the contents of a directory and streams the results
Expand Down Expand Up @@ -71,7 +71,7 @@ class DirectoryReader {
call.safe(facade.fs.readdir, dir.path, (err, items) => {
if (err) {
// fs.readdir threw an error
this.emit('error', err);
this.emit("error", err);
return this.finishedReadingDirectory();
}

Expand All @@ -86,7 +86,7 @@ class DirectoryReader {
catch (err2) {
// facade.forEach threw an error
// (probably because fs.readdir returned an invalid result)
this.emit('error', err2);
this.emit("error", err2);
this.finishedReadingDirectory();
}
});
Expand Down Expand Up @@ -155,9 +155,9 @@ class DirectoryReader {
options.stats || // the user wants fs.Stats objects returned
options.recurseFn || // we need fs.Stats for the recurse function
options.filterFn || // we need fs.Stats for the filter function
EventEmitter.listenerCount(stream, 'file') || // we need the fs.Stats to know if it's a file
EventEmitter.listenerCount(stream, 'directory') || // we need the fs.Stats to know if it's a directory
EventEmitter.listenerCount(stream, 'symlink'); // we need the fs.Stats to know if it's a symlink
EventEmitter.listenerCount(stream, "file") || // we need the fs.Stats to know if it's a file
EventEmitter.listenerCount(stream, "directory") || // we need the fs.Stats to know if it's a directory
EventEmitter.listenerCount(stream, "symlink"); // we need the fs.Stats to know if it's a symlink

// If we don't need stats, then exit early
if (!needStats) {
Expand All @@ -171,7 +171,7 @@ class DirectoryReader {
stat(options.facade.fs, fullPath, (err, stats) => {
if (err) {
// fs.stat threw an error
this.emit('error', err);
this.emit("error", err);
return done();
}

Expand All @@ -189,7 +189,7 @@ class DirectoryReader {
this.queue.push({
path: fullPath,
basePath: itemPath + options.sep,
posixBasePath: posixPath + '/',
posixBasePath: posixPath + "/",
depth: dir.depth + 1,
});
}
Expand All @@ -209,7 +209,7 @@ class DirectoryReader {
catch (err2) {
// An error occurred while processing the item
// (probably during a user-specified function, such as options.deep, options.filter, etc.)
this.emit('error', err2);
this.emit("error", err2);
done();
}
});
Expand Down Expand Up @@ -247,13 +247,13 @@ class DirectoryReader {
this.shouldRead = stream.push(chunk.data);
}
catch (err) {
this.emit('error', err);
this.emit("error", err);
}

// Also emit specific events, based on the type of chunk
chunk.file && this.emit('file', chunk.data);
chunk.symlink && this.emit('symlink', chunk.data);
chunk.directory && this.emit('directory', chunk.data);
chunk.file && this.emit("file", chunk.data);
chunk.symlink && this.emit("symlink", chunk.data);
chunk.directory && this.emit("directory", chunk.data);
}

/**
Expand Down Expand Up @@ -295,7 +295,7 @@ class DirectoryReader {
// An error occurred in the user's code.
// In Sync and Async modes, this will return an error.
// In Streaming mode, we emit an "error" event, but continue processing
this.emit('error', err);
this.emit("error", err);
}
}
else {
Expand Down Expand Up @@ -335,7 +335,7 @@ class DirectoryReader {
// An error occurred in the user's code.
// In Sync and Async modes, this will return an error.
// In Streaming mode, we emit an "error" event, but continue processing
this.emit('error', err);
this.emit("error", err);
}
}
else {
Expand All @@ -358,13 +358,13 @@ class DirectoryReader {
stream.emit(eventName, data);
}
catch (err) {
if (eventName === 'error') {
if (eventName === "error") {
// Don't recursively emit "error" events.
// If the first one fails, then just throw
throw err;
}
else {
stream.emit('error', err);
stream.emit("error", err);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
"use strict";

const readdirSync = require('./sync');
const readdirAsync = require('./async');
const readdirStream = require('./stream');
const readdirSync = require("./sync");
const readdirAsync = require("./async");
const readdirStream = require("./stream");

module.exports = exports = readdirAsyncPath;
exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath;
Expand Down
50 changes: 25 additions & 25 deletions lib/normalize-options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
"use strict";

const path = require('path');
const globToRegExp = require('glob-to-regexp');
const path = require("path");
const globToRegExp = require("glob-to-regexp");

module.exports = normalizeOptions;

Expand Down Expand Up @@ -55,92 +55,92 @@ function normalizeOptions (options, internalOptions) {
if (options === null || options === undefined) {
options = {};
}
else if (typeof options !== 'object') {
throw new TypeError('options must be an object');
else if (typeof options !== "object") {
throw new TypeError("options must be an object");
}

let recurseDepth, recurseFn, recurseRegExp, recurseGlob, deep = options.deep;
if (deep === null || deep === undefined) {
recurseDepth = 0;
}
else if (typeof deep === 'boolean') {
else if (typeof deep === "boolean") {
recurseDepth = deep ? Infinity : 0;
}
else if (typeof deep === 'number') {
else if (typeof deep === "number") {
if (deep < 0 || isNaN(deep)) {
throw new Error('options.deep must be a positive number');
throw new Error("options.deep must be a positive number");
}
else if (Math.floor(deep) !== deep) {
throw new Error('options.deep must be an integer');
throw new Error("options.deep must be an integer");
}
else {
recurseDepth = deep;
}
}
else if (typeof deep === 'function') {
else if (typeof deep === "function") {
recurseDepth = Infinity;
recurseFn = deep;
}
else if (deep instanceof RegExp) {
recurseDepth = Infinity;
recurseRegExp = deep;
}
else if (typeof deep === 'string' && deep.length > 0) {
else if (typeof deep === "string" && deep.length > 0) {
recurseDepth = Infinity;
recurseGlob = globToRegExp(deep, { extended: true, globstar: true });
}
else {
throw new TypeError('options.deep must be a boolean, number, function, regular expression, or glob pattern');
throw new TypeError("options.deep must be a boolean, number, function, regular expression, or glob pattern");
}

let filterFn, filterRegExp, filterGlob, filter = options.filter;
if (filter !== null && filter !== undefined) {
if (typeof filter === 'function') {
if (typeof filter === "function") {
filterFn = filter;
}
else if (filter instanceof RegExp) {
filterRegExp = filter;
}
else if (typeof filter === 'string' && filter.length > 0) {
else if (typeof filter === "string" && filter.length > 0) {
filterGlob = globToRegExp(filter, { extended: true, globstar: true });
}
else {
throw new TypeError('options.filter must be a function, regular expression, or glob pattern');
throw new TypeError("options.filter must be a function, regular expression, or glob pattern");
}
}

let sep = options.sep;
if (sep === null || sep === undefined) {
sep = path.sep;
}
else if (typeof sep !== 'string') {
throw new TypeError('options.sep must be a string');
else if (typeof sep !== "string") {
throw new TypeError("options.sep must be a string");
}

let basePath = options.basePath;
if (basePath === null || basePath === undefined) {
basePath = '';
basePath = "";
}
else if (typeof basePath === 'string') {
else if (typeof basePath === "string") {
// Append a path separator to the basePath, if necessary
if (basePath && basePath.substr(-1) !== sep) {
basePath += sep;
}
}
else {
throw new TypeError('options.basePath must be a string');
throw new TypeError("options.basePath must be a string");
}

// Convert the basePath to POSIX (forward slashes)
// so that glob pattern matching works consistently, even on Windows
let posixBasePath = basePath;
if (posixBasePath && sep !== '/') {
posixBasePath = posixBasePath.replace(new RegExp('\\' + sep, 'g'), '/');
if (posixBasePath && sep !== "/") {
posixBasePath = posixBasePath.replace(new RegExp("\\" + sep, "g"), "/");

/* istanbul ignore if */
if (isWindows) {
// Convert Windows root paths (C:\) and UNCs (\\) to POSIX root paths
posixBasePath = posixBasePath.replace(/^([a-zA-Z]\:\/|\/\/)/, '/');
posixBasePath = posixBasePath.replace(/^([a-zA-Z]\:\/|\/\/)/, "/");
}
}

Expand All @@ -150,13 +150,13 @@ function normalizeOptions (options, internalOptions) {
// The user didn't provide their own facades, so use our internal ones
facade = internalOptions.facade;
}
else if (typeof options.fs === 'object') {
else if (typeof options.fs === "object") {
// Merge the internal facade methods with the user-provided `fs` facades
facade = Object.assign({}, internalOptions.facade);
facade.fs = Object.assign({}, internalOptions.facade.fs, options.fs);
}
else {
throw new TypeError('options.fs must be an object');
throw new TypeError("options.fs must be an object");
}

return {
Expand Down
4 changes: 2 additions & 2 deletions lib/stat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
"use strict";

const call = require('./call');
const call = require("./call");

module.exports = stat;

Expand Down
8 changes: 4 additions & 4 deletions lib/stream/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
"use strict";

module.exports = readdirStream;

const DirectoryReader = require('../directory-reader');
const DirectoryReader = require("../directory-reader");

let streamFacade = {
fs: require('fs'),
forEach: require('../async/for-each'),
fs: require("fs"),
forEach: require("../async/for-each"),
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/sync/for-each.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

module.exports = syncForEach;

Expand Down
6 changes: 3 additions & 3 deletions lib/sync/fs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
"use strict";

const fs = require('fs');
const call = require('../call');
const fs = require("fs");
const call = require("../call");

/**
* A facade around {@link fs.readdirSync} that allows it to be called
Expand Down
Loading

0 comments on commit 74767c6

Please sign in to comment.