Added Gulp.js for compiling SCSS stylesheets
This commit is contained in:
59
node_modules/vinyl-fs/lib/dest/write-contents/index.js
generated
vendored
Normal file
59
node_modules/vinyl-fs/lib/dest/write-contents/index.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
var through = require('through2');
|
||||
|
||||
var writeDir = require('./write-dir');
|
||||
var writeStream = require('./write-stream');
|
||||
var writeBuffer = require('./write-buffer');
|
||||
var writeSymbolicLink = require('./write-symbolic-link');
|
||||
|
||||
var fo = require('../../file-operations');
|
||||
|
||||
function writeContents(optResolver) {
|
||||
|
||||
function writeFile(file, enc, callback) {
|
||||
// Write it as a symlink
|
||||
if (file.isSymbolic()) {
|
||||
return writeSymbolicLink(file, optResolver, onWritten);
|
||||
}
|
||||
|
||||
// If directory then mkdirp it
|
||||
if (file.isDirectory()) {
|
||||
return writeDir(file, optResolver, onWritten);
|
||||
}
|
||||
|
||||
// Stream it to disk yo
|
||||
if (file.isStream()) {
|
||||
return writeStream(file, optResolver, onWritten);
|
||||
}
|
||||
|
||||
// Write it like normal
|
||||
if (file.isBuffer()) {
|
||||
return writeBuffer(file, optResolver, onWritten);
|
||||
}
|
||||
|
||||
// If no contents then do nothing
|
||||
if (file.isNull()) {
|
||||
return onWritten();
|
||||
}
|
||||
|
||||
// This is invoked by the various writeXxx modules when they've finished
|
||||
// writing the contents.
|
||||
function onWritten(writeErr) {
|
||||
var flags = fo.getFlags({
|
||||
overwrite: optResolver.resolve('overwrite', file),
|
||||
append: optResolver.resolve('append', file),
|
||||
});
|
||||
if (fo.isFatalOverwriteError(writeErr, flags)) {
|
||||
return callback(writeErr);
|
||||
}
|
||||
|
||||
callback(null, file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return through.obj(writeFile);
|
||||
}
|
||||
|
||||
module.exports = writeContents;
|
31
node_modules/vinyl-fs/lib/dest/write-contents/write-buffer.js
generated
vendored
Normal file
31
node_modules/vinyl-fs/lib/dest/write-contents/write-buffer.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
var fo = require('../../file-operations');
|
||||
|
||||
function writeBuffer(file, optResolver, onWritten) {
|
||||
var flags = fo.getFlags({
|
||||
overwrite: optResolver.resolve('overwrite', file),
|
||||
append: optResolver.resolve('append', file),
|
||||
});
|
||||
var opt = {
|
||||
mode: file.stat.mode,
|
||||
flags: flags,
|
||||
};
|
||||
|
||||
fo.writeFile(file.path, file.contents, opt, onWriteFile);
|
||||
|
||||
function onWriteFile(writeErr, fd) {
|
||||
if (writeErr) {
|
||||
return fo.closeFd(writeErr, fd, onWritten);
|
||||
}
|
||||
|
||||
fo.updateMetadata(fd, file, onUpdate);
|
||||
|
||||
function onUpdate(updateErr) {
|
||||
fo.closeFd(updateErr, fd, onWritten);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = writeBuffer;
|
51
node_modules/vinyl-fs/lib/dest/write-contents/write-dir.js
generated
vendored
Normal file
51
node_modules/vinyl-fs/lib/dest/write-contents/write-dir.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
|
||||
var mkdirp = require('fs-mkdirp-stream/mkdirp');
|
||||
|
||||
var fo = require('../../file-operations');
|
||||
|
||||
function writeDir(file, optResolver, onWritten) {
|
||||
mkdirp(file.path, file.stat.mode, onMkdirp);
|
||||
|
||||
function onMkdirp(mkdirpErr) {
|
||||
if (mkdirpErr) {
|
||||
return onWritten(mkdirpErr);
|
||||
}
|
||||
|
||||
fs.open(file.path, 'r', onOpen);
|
||||
}
|
||||
|
||||
function onOpen(openErr, fd) {
|
||||
// If we don't have access, just move along
|
||||
if (isInaccessible(openErr)) {
|
||||
return fo.closeFd(null, fd, onWritten);
|
||||
}
|
||||
|
||||
if (openErr) {
|
||||
return fo.closeFd(openErr, fd, onWritten);
|
||||
}
|
||||
|
||||
fo.updateMetadata(fd, file, onUpdate);
|
||||
|
||||
function onUpdate(updateErr) {
|
||||
fo.closeFd(updateErr, fd, onWritten);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isInaccessible(err) {
|
||||
if (!err) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (err.code === 'EACCES') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = writeDir;
|
62
node_modules/vinyl-fs/lib/dest/write-contents/write-stream.js
generated
vendored
Normal file
62
node_modules/vinyl-fs/lib/dest/write-contents/write-stream.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var fo = require('../../file-operations');
|
||||
var readStream = require('../../src/read-contents/read-stream');
|
||||
|
||||
function writeStream(file, optResolver, onWritten) {
|
||||
var flags = fo.getFlags({
|
||||
overwrite: optResolver.resolve('overwrite', file),
|
||||
append: optResolver.resolve('append', file),
|
||||
});
|
||||
var opt = {
|
||||
mode: file.stat.mode,
|
||||
// TODO: need to test this
|
||||
flags: flags,
|
||||
};
|
||||
|
||||
// TODO: is this the best API?
|
||||
var outStream = fo.createWriteStream(file.path, opt, onFlush);
|
||||
|
||||
file.contents.once('error', onComplete);
|
||||
outStream.once('error', onComplete);
|
||||
outStream.once('finish', onComplete);
|
||||
|
||||
// TODO: should this use a clone?
|
||||
file.contents.pipe(outStream);
|
||||
|
||||
function onComplete(streamErr) {
|
||||
// Cleanup event handlers before closing
|
||||
file.contents.removeListener('error', onComplete);
|
||||
outStream.removeListener('error', onComplete);
|
||||
outStream.removeListener('finish', onComplete);
|
||||
|
||||
// Need to guarantee the fd is closed before forwarding the error
|
||||
outStream.once('close', onClose);
|
||||
outStream.end();
|
||||
|
||||
function onClose(closeErr) {
|
||||
onWritten(streamErr || closeErr);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
function onFlush(fd, callback) {
|
||||
// TODO: removing this before readStream because it replaces the stream
|
||||
file.contents.removeListener('error', onComplete);
|
||||
|
||||
// TODO: this is doing sync stuff & the callback seems unnecessary
|
||||
// TODO: Replace the contents stream or use a clone?
|
||||
readStream(file, complete);
|
||||
|
||||
function complete() {
|
||||
if (typeof fd !== 'number') {
|
||||
return callback();
|
||||
}
|
||||
|
||||
fo.updateMetadata(fd, file, callback);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = writeStream;
|
77
node_modules/vinyl-fs/lib/dest/write-contents/write-symbolic-link.js
generated
vendored
Normal file
77
node_modules/vinyl-fs/lib/dest/write-contents/write-symbolic-link.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
var path = require('path');
|
||||
|
||||
var fo = require('../../file-operations');
|
||||
|
||||
var isWindows = (os.platform() === 'win32');
|
||||
|
||||
function writeSymbolicLink(file, optResolver, onWritten) {
|
||||
if (!file.symlink) {
|
||||
return onWritten(new Error('Missing symlink property on symbolic vinyl'));
|
||||
}
|
||||
|
||||
var isRelative = optResolver.resolve('relativeSymlinks', file);
|
||||
var flags = fo.getFlags({
|
||||
overwrite: optResolver.resolve('overwrite', file),
|
||||
append: optResolver.resolve('append', file),
|
||||
});
|
||||
|
||||
if (!isWindows) {
|
||||
// On non-Windows, just use 'file'
|
||||
return createLinkWithType('file');
|
||||
}
|
||||
|
||||
fo.reflectStat(file.symlink, file, onReflect);
|
||||
|
||||
function onReflect(statErr) {
|
||||
if (statErr && statErr.code !== 'ENOENT') {
|
||||
return onWritten(statErr);
|
||||
}
|
||||
|
||||
// This option provides a way to create a Junction instead of a
|
||||
// Directory symlink on Windows. This comes with the following caveats:
|
||||
// * NTFS Junctions cannot be relative.
|
||||
// * NTFS Junctions MUST be directories.
|
||||
// * NTFS Junctions must be on the same file system.
|
||||
// * Most products CANNOT detect a directory is a Junction:
|
||||
// This has the side effect of possibly having a whole directory
|
||||
// deleted when a product is deleting the Junction directory.
|
||||
// For example, JetBrains product lines will delete the entire contents
|
||||
// of the TARGET directory because the product does not realize it's
|
||||
// a symlink as the JVM and Node return false for isSymlink.
|
||||
|
||||
// This function is Windows only, so we don't need to check again
|
||||
var useJunctions = optResolver.resolve('useJunctions', file);
|
||||
|
||||
var dirType = useJunctions ? 'junction' : 'dir';
|
||||
// Dangling links are always 'file'
|
||||
var type = !statErr && file.isDirectory() ? dirType : 'file';
|
||||
|
||||
createLinkWithType(type);
|
||||
}
|
||||
|
||||
function createLinkWithType(type) {
|
||||
// This is done after prepare() to use the adjusted file.base property
|
||||
if (isRelative && type !== 'junction') {
|
||||
file.symlink = path.relative(file.base, file.symlink);
|
||||
}
|
||||
|
||||
var opts = {
|
||||
flags: flags,
|
||||
type: type,
|
||||
};
|
||||
fo.symlink(file.symlink, file.path, opts, onSymlink);
|
||||
|
||||
function onSymlink(symlinkErr) {
|
||||
if (symlinkErr) {
|
||||
return onWritten(symlinkErr);
|
||||
}
|
||||
|
||||
fo.reflectLinkStat(file.path, file, onWritten);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = writeSymbolicLink;
|
Reference in New Issue
Block a user