diff --git a/README.md b/README.md index 47a85f1e..df45435c 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,13 @@ While Vinyl provides a clean way to describe a file, we now need a way to access var map = require('map-stream'); var vfs = require('vinyl-fs'); -var log = function(file, cb) { +var log = function (file, cb) { console.log(file.path); cb(null, file); }; -vfs.src(['./js/**/*.js', '!./js/vendor/*.js']) +vfs + .src(['./js/**/*.js', '!./js/vendor/*.js']) .pipe(map(log)) .pipe(vfs.dest('./output')); ``` @@ -41,7 +42,7 @@ vfs.src(['./js/**/*.js', '!./js/vendor/*.js']) Takes a glob string or an array of glob strings as the first argument and an options object as the second. Returns a stream of [vinyl] `File` objects. -__Note: UTF-8 BOM will be removed from all UTF-8 files read with `.src` unless disabled in the options.__ +**Note: UTF-8 BOM will be removed from all UTF-8 files read with `.src` unless disabled in the options.** #### Globs @@ -50,13 +51,13 @@ Globs are executed in order, so negations should follow positive globs. For example: ```js -fs.src(['!b*', '*']) +fs.src(['!b*', '*']); ``` would not exclude any files, but the following would exclude all files starting with "b": ```js -fs.src(['*', '!b*']) +fs.src(['*', '!b*']); ``` #### Options @@ -109,7 +110,7 @@ Default: `'utf8'` ##### `options.sourcemaps` -Enables sourcemap support on files passed through the stream. Will load inline sourcemaps and resolve sourcemap links from files. +Enables sourcemap support on files passed through the stream. Will load inline sourcemaps and resolve sourcemap links from files. Type: `Boolean` @@ -127,7 +128,7 @@ Default: `true` Whether or not you want globs to match on dot files (e.g. `.gitignore`). -__Note: This option is not resolved from a function because it is passed verbatim to anymatch.__ +**Note: This option is not resolved from a function because it is passed verbatim to anymatch.** Type: `Boolean` @@ -145,16 +146,17 @@ Returns a stream that accepts [vinyl] `File` objects, writes them to disk at the Once the file is written to disk, an attempt is made to determine if the `stat.mode`, `stat.mtime` and `stat.atime` of the [vinyl] `File` object differ from the file on the filesystem. If they differ and the running process owns the file, the corresponding filesystem metadata is updated. If they don't differ or the process doesn't own the file, the attempt is skipped silently. -__This functionality is disabled on Windows operating systems or any other OS that doesn't support `process.getuid` or `process.geteuid` in node. This is due to Windows having very unexpected results through usage of `fs.fchmod` and `fs.futimes`.__ +**This functionality is disabled on Windows operating systems or any other OS that doesn't support `process.getuid` or `process.geteuid` in node. This is due to Windows having very unexpected results through usage of `fs.fchmod` and `fs.futimes`.** -__Note: The `fs.futimes()` method internally converts `stat.mtime` and `stat.atime` timestamps to seconds; this division by `1000` may cause some loss of precision in 32-bit Node.js.__ +**Note: The `fs.futimes()` method internally converts `stat.mtime` and `stat.atime` timestamps to seconds; this division by `1000` may cause some loss of precision in 32-bit Node.js.** If the file has a `symlink` attribute specifying a target path, then a symlink will be created. -__Note: The file will be modified after being written to this stream.__ - - `cwd`, `base`, and `path` will be overwritten to match the folder. - - `stat` will be updated to match the file on the filesystem. - - `contents` will have it's position reset to the beginning if it is a stream. +**Note: The file will be modified after being written to this stream.** + +- `cwd`, `base`, and `path` will be overwritten to match the folder. +- `stat` will be updated to match the file on the filesystem. +- `contents` will have it's position reset to the beginning if it is a stream. #### Options @@ -214,7 +216,7 @@ Default: `'utf8'`. ##### `options.sourcemaps` -Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`. +Enables sourcemap support on files passed through the stream. Will write inline soucemaps if specified as `true`. Specifying a `String` path will write external sourcemaps at the given path. Examples: @@ -235,7 +237,7 @@ Default: `undefined` (do not write sourcemaps) When creating a symlink, whether or not the created symlink should be relative. If `false`, the symlink will be absolute. -__Note: This option will be ignored if a `junction` is being created, as they must be absolute.__ +**Note: This option will be ignored if a `junction` is being created, as they must be absolute.** Type: `Boolean` @@ -255,13 +257,14 @@ Default: `true` Takes a folder path string or a function as the first argument and an options object as the second. If given a function, it will be called with each [vinyl] `File` object and must return a folder path. Returns a stream that accepts [vinyl] `File` objects, creates a symbolic link (i.e. symlink) at the folder/cwd specified, and passes them downstream so you can keep piping these around. -__Note: The file will be modified after being written to this stream.__ - - `cwd`, `base`, and `path` will be overwritten to match the folder. - - `stat` will be updated to match the symlink on the filesystem. - - `contents` will be set to `null`. - - `symlink` will be added or replaced to be the original path. +**Note: The file will be modified after being written to this stream.** + +- `cwd`, `base`, and `path` will be overwritten to match the folder. +- `stat` will be updated to match the symlink on the filesystem. +- `contents` will be set to `null`. +- `symlink` will be added or replaced to be the original path. -__Note: On Windows, directory links are created using Junctions by default. Use the `useJunctions` option to disable this behavior.__ +**Note: On Windows, directory links are created using Junctions by default. Use the `useJunctions` option to disable this behavior.** #### Options @@ -296,7 +299,7 @@ Default: `true` (always overwrite existing files) Whether or not the created symlinks should be relative. If `false`, the symlink will be absolute. -__Note: This option will be ignored if a `junction` is being created, as they must be absolute.__ +**Note: This option will be ignored if a `junction` is being created, as they must be absolute.** Type: `Boolean` diff --git a/lib/dest/index.js b/lib/dest/index.js index a181350b..519b76ba 100644 --- a/lib/dest/index.js +++ b/lib/dest/index.js @@ -18,8 +18,10 @@ var folderConfig = { function dest(outFolder, opt) { if (!outFolder) { - throw new Error('Invalid dest() folder argument.' + - ' Please specify a non-empty string or a function.'); + throw new Error( + 'Invalid dest() folder argument.' + + ' Please specify a non-empty string or a function.' + ); } var optResolver = createResolver(config, opt); diff --git a/lib/dest/options.js b/lib/dest/options.js index ecdc63f5..47c0c514 100644 --- a/lib/dest/options.js +++ b/lib/dest/options.js @@ -9,7 +9,7 @@ var config = { }, mode: { type: 'number', - default: function(file) { + default: function (file) { return file.stat ? file.stat.mode : null; }, }, diff --git a/lib/dest/prepare.js b/lib/dest/prepare.js index 1cb97611..08d5c1f1 100644 --- a/lib/dest/prepare.js +++ b/lib/dest/prepare.js @@ -35,7 +35,7 @@ function prepareWrite(folderResolver, optResolver) { file.path = writePath; if (!file.isSymbolic()) { var mode = optResolver.resolve('mode', file); - file.stat = (file.stat || new fs.Stats()); + file.stat = file.stat || new fs.Stats(); file.stat.mode = mode; } diff --git a/lib/dest/sourcemap.js b/lib/dest/sourcemap.js index e10106d7..7f648357 100644 --- a/lib/dest/sourcemap.js +++ b/lib/dest/sourcemap.js @@ -4,7 +4,6 @@ var Transform = require('streamx').Transform; var sourcemap = require('vinyl-sourcemap'); function sourcemapStream(optResolver) { - function saveSourcemap(file, callback) { var self = this; @@ -14,7 +13,7 @@ function sourcemapStream(optResolver) { return callback(null, file); } - var srcMapLocation = (typeof srcMap === 'string' ? srcMap : undefined); + var srcMapLocation = typeof srcMap === 'string' ? srcMap : undefined; sourcemap.write(file, srcMapLocation, onWrite); diff --git a/lib/dest/write-contents/index.js b/lib/dest/write-contents/index.js index 69ced5a1..5d558196 100644 --- a/lib/dest/write-contents/index.js +++ b/lib/dest/write-contents/index.js @@ -10,7 +10,6 @@ var writeSymbolicLink = require('./write-symbolic-link'); var fo = require('../../file-operations'); function writeContents(optResolver) { - function writeFile(file, callback) { // Write it as a symlink if (file.isSymbolic()) { @@ -50,7 +49,6 @@ function writeContents(optResolver) { callback(null, file); } - } return new Transform({ diff --git a/lib/dest/write-contents/write-buffer.js b/lib/dest/write-contents/write-buffer.js index b7ee7da2..242fe2fb 100644 --- a/lib/dest/write-contents/write-buffer.js +++ b/lib/dest/write-contents/write-buffer.js @@ -41,7 +41,6 @@ function writeBuffer(file, optResolver, onWritten) { fo.closeFd(updateErr, fd, onWritten); } } - } module.exports = writeBuffer; diff --git a/lib/dest/write-contents/write-dir.js b/lib/dest/write-contents/write-dir.js index d182728b..8b632e11 100644 --- a/lib/dest/write-contents/write-dir.js +++ b/lib/dest/write-contents/write-dir.js @@ -33,7 +33,6 @@ function writeDir(file, optResolver, onWritten) { fo.closeFd(updateErr, fd, onWritten); } } - } function isInaccessible(err) { diff --git a/lib/dest/write-contents/write-symbolic-link.js b/lib/dest/write-contents/write-symbolic-link.js index 411a8bdb..e1dc42d6 100644 --- a/lib/dest/write-contents/write-symbolic-link.js +++ b/lib/dest/write-contents/write-symbolic-link.js @@ -5,7 +5,7 @@ var path = require('path'); var fo = require('../../file-operations'); -var isWindows = (os.platform() === 'win32'); +var isWindows = os.platform() === 'win32'; function writeSymbolicLink(file, optResolver, onWritten) { if (!file.symlink) { diff --git a/lib/src/prepare.js b/lib/src/prepare.js index 3dbd5524..0f9a16ae 100644 --- a/lib/src/prepare.js +++ b/lib/src/prepare.js @@ -3,9 +3,7 @@ var Transform = require('streamx').Transform; function prepareRead(optResolver) { - function normalize(file, callback) { - var since = optResolver.resolve('since', file); // Skip this file if since option is set and current file is too old diff --git a/lib/src/read-contents/index.js b/lib/src/read-contents/index.js index f09360cc..b6f1b475 100644 --- a/lib/src/read-contents/index.js +++ b/lib/src/read-contents/index.js @@ -8,9 +8,7 @@ var readBuffer = require('./read-buffer'); var readSymbolicLink = require('./read-symbolic-link'); function readContents(optResolver) { - function readFile(file, callback) { - // Skip reading contents if read option says so var read = optResolver.resolve('read', file); if (!read) { diff --git a/lib/src/resolve-symlinks.js b/lib/src/resolve-symlinks.js index 945831cb..628a0017 100644 --- a/lib/src/resolve-symlinks.js +++ b/lib/src/resolve-symlinks.js @@ -4,10 +4,8 @@ var Transform = require('streamx').Transform; var fo = require('../file-operations'); function resolveSymlinks(optResolver) { - // A stat property is exposed on file objects as a (wanted) side effect function resolveFile(file, callback) { - fo.reflectLinkStat(file.path, file, onReflect); function onReflect(statErr) { diff --git a/lib/src/sourcemap.js b/lib/src/sourcemap.js index 651dc49b..42893aba 100644 --- a/lib/src/sourcemap.js +++ b/lib/src/sourcemap.js @@ -4,7 +4,6 @@ var Transform = require('streamx').Transform; var sourcemap = require('vinyl-sourcemap'); function sourcemapStream(optResolver) { - function addSourcemap(file, callback) { var srcMap = optResolver.resolve('sourcemaps', file); diff --git a/lib/src/wrap-vinyl.js b/lib/src/wrap-vinyl.js index 605bd1c2..00dffef7 100644 --- a/lib/src/wrap-vinyl.js +++ b/lib/src/wrap-vinyl.js @@ -4,9 +4,7 @@ var File = require('vinyl'); var Transform = require('streamx').Transform; function wrapVinyl() { - function wrapFile(globFile, callback) { - var file = new File(globFile); callback(null, file); diff --git a/lib/symlink/index.js b/lib/symlink/index.js index a9a006dd..1ff977c8 100644 --- a/lib/symlink/index.js +++ b/lib/symlink/index.js @@ -17,8 +17,10 @@ var folderConfig = { function symlink(outFolder, opt) { if (!outFolder) { - throw new Error('Invalid symlink() folder argument.' + - ' Please specify a non-empty string or a function.'); + throw new Error( + 'Invalid symlink() folder argument.' + + ' Please specify a non-empty string or a function.' + ); } var optResolver = createResolver(config, opt); diff --git a/lib/symlink/link-file.js b/lib/symlink/link-file.js index ecebe182..fe2543a5 100644 --- a/lib/symlink/link-file.js +++ b/lib/symlink/link-file.js @@ -7,10 +7,9 @@ var Transform = require('streamx').Transform; var fo = require('../file-operations'); -var isWindows = (os.platform() === 'win32'); +var isWindows = os.platform() === 'win32'; function linkStream(optResolver) { - function linkFile(file, callback) { var isRelative = optResolver.resolve('relativeSymlinks', file); var flags = fo.getFlags({ diff --git a/lib/symlink/prepare.js b/lib/symlink/prepare.js index 49f0b2e3..c94e145c 100644 --- a/lib/symlink/prepare.js +++ b/lib/symlink/prepare.js @@ -32,7 +32,7 @@ function prepareSymlink(folderResolver, optResolver) { // Wire up new properties // Note: keep the target stats for now, we may need them in link-file - file.stat = (file.stat || new fs.Stats()); + file.stat = file.stat || new fs.Stats(); file.cwd = cwd; file.base = basePath; // This is the path we are linking *TO* diff --git a/test/utils/always.js b/test/utils/always.js index 02b6b6c7..9dd5f539 100644 --- a/test/utils/always.js +++ b/test/utils/always.js @@ -1,7 +1,7 @@ 'use strict'; function always(value) { - return function() { + return function () { return value; }; } diff --git a/test/utils/apply-umask.js b/test/utils/apply-umask.js index 8cf524bf..8c951e8b 100644 --- a/test/utils/apply-umask.js +++ b/test/utils/apply-umask.js @@ -5,7 +5,7 @@ function applyUmask(mode) { mode = parseInt(mode, 8); } - return (mode & ~process.umask()); + return mode & ~process.umask(); } module.exports = applyUmask; diff --git a/test/utils/break-prototype.js b/test/utils/break-prototype.js index 9ced60e9..7e033dba 100644 --- a/test/utils/break-prototype.js +++ b/test/utils/break-prototype.js @@ -5,7 +5,7 @@ var File = require('vinyl'); function breakPrototype(file) { // Set up a broken prototype var oldProto = {}; - Object.getOwnPropertyNames(File.prototype).forEach(function(key) { + Object.getOwnPropertyNames(File.prototype).forEach(function (key) { if (key !== 'isSymbolic') { var desc = Object.getOwnPropertyDescriptor(File.prototype, key); Object.defineProperty(oldProto, key, desc); diff --git a/test/utils/cleanup.js b/test/utils/cleanup.js index 5189a539..9a7b11fc 100644 --- a/test/utils/cleanup.js +++ b/test/utils/cleanup.js @@ -4,7 +4,7 @@ var rimraf = require('rimraf'); var sinon = require('sinon'); function cleanup(glob) { - return function(cb) { + return function (cb) { this.timeout(0); sinon.restore(); diff --git a/test/utils/is-windows.js b/test/utils/is-windows.js index fdbb3e6f..93b75c06 100644 --- a/test/utils/is-windows.js +++ b/test/utils/is-windows.js @@ -2,6 +2,6 @@ var os = require('os'); -var isWindows = (os.platform() === 'win32'); +var isWindows = os.platform() === 'win32'; module.exports = isWindows;