Skip to content

Commit

Permalink
chore: Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
phated authored and actions-user committed Jun 11, 2023
1 parent 910c8a5 commit 0baaf36
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 52 deletions.
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
```
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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`

Expand All @@ -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`

Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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`

Expand All @@ -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

Expand Down Expand Up @@ -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`

Expand Down
6 changes: 4 additions & 2 deletions lib/dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/dest/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var config = {
},
mode: {
type: 'number',
default: function(file) {
default: function (file) {
return file.stat ? file.stat.mode : null;
},
},
Expand Down
2 changes: 1 addition & 1 deletion lib/dest/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/dest/sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var Transform = require('streamx').Transform;
var sourcemap = require('vinyl-sourcemap');

function sourcemapStream(optResolver) {

function saveSourcemap(file, callback) {
var self = this;

Expand All @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions lib/dest/write-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -50,7 +49,6 @@ function writeContents(optResolver) {

callback(null, file);
}

}

return new Transform({
Expand Down
1 change: 0 additions & 1 deletion lib/dest/write-contents/write-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function writeBuffer(file, optResolver, onWritten) {
fo.closeFd(updateErr, fd, onWritten);
}
}

}

module.exports = writeBuffer;
1 change: 0 additions & 1 deletion lib/dest/write-contents/write-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function writeDir(file, optResolver, onWritten) {
fo.closeFd(updateErr, fd, onWritten);
}
}

}

function isInaccessible(err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/dest/write-contents/write-symbolic-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions lib/src/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/src/read-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions lib/src/resolve-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion lib/src/sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions lib/src/wrap-vinyl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions lib/symlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions lib/symlink/link-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion lib/symlink/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion test/utils/always.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

function always(value) {
return function() {
return function () {
return value;
};
}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/apply-umask.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function applyUmask(mode) {
mode = parseInt(mode, 8);
}

return (mode & ~process.umask());
return mode & ~process.umask();
}

module.exports = applyUmask;
2 changes: 1 addition & 1 deletion test/utils/break-prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/utils/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/utils/is-windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

var os = require('os');

var isWindows = (os.platform() === 'win32');
var isWindows = os.platform() === 'win32';

module.exports = isWindows;

0 comments on commit 0baaf36

Please sign in to comment.