| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/gulp-concat/ |
Upload File : |
'use strict';
var through = require('through2');
var path = require('path');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var File = gutil.File;
var Concat = require('concat-with-sourcemaps');
// file can be a vinyl file object or a string
// when a string it will construct a new one
module.exports = function(file, opt) {
if (!file) {
throw new PluginError('gulp-concat', 'Missing file option for gulp-concat');
}
opt = opt || {};
// to preserve existing |undefined| behaviour and to introduce |newLine: ""| for binaries
if (typeof opt.newLine !== 'string') {
opt.newLine = gutil.linefeed;
}
var isUsingSourceMaps = false;
var latestFile;
var latestMod;
var fileName;
var concat;
if (typeof file === 'string') {
fileName = file;
} else if (typeof file.path === 'string') {
fileName = path.basename(file.path);
} else {
throw new PluginError('gulp-concat', 'Missing path in file options for gulp-concat');
}
function bufferContents(file, enc, cb) {
// ignore empty files
if (file.isNull()) {
cb();
return;
}
// we don't do streams (yet)
if (file.isStream()) {
this.emit('error', new PluginError('gulp-concat', 'Streaming not supported'));
cb();
return;
}
// enable sourcemap support for concat
// if a sourcemap initialized file comes in
if (file.sourceMap && isUsingSourceMaps === false) {
isUsingSourceMaps = true;
}
// set latest file if not already set,
// or if the current file was modified more recently.
if (!latestMod || file.stat && file.stat.mtime > latestMod) {
latestFile = file;
latestMod = file.stat && file.stat.mtime;
}
// construct concat instance
if (!concat) {
concat = new Concat(isUsingSourceMaps, fileName, opt.newLine);
}
// add file to concat instance
concat.add(file.relative, file.contents, file.sourceMap);
cb();
}
function endStream(cb) {
// no files passed in, no file goes out
if (!latestFile || !concat) {
cb();
return;
}
var joinedFile;
// if file opt was a file path
// clone everything from the latest file
if (typeof file === 'string') {
joinedFile = latestFile.clone({contents: false});
joinedFile.path = path.join(latestFile.base, file);
} else {
joinedFile = new File(file);
}
joinedFile.contents = concat.content;
if (concat.sourceMapping) {
joinedFile.sourceMap = JSON.parse(concat.sourceMap);
}
this.push(joinedFile);
cb();
}
return through.obj(bufferContents, endStream);
};