/usr/lib/nodejs/gulp-rename/index.js is in node-gulp-rename 1.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 'use strict';
var Stream = require('stream');
var Path = require('path');
function gulpRename(obj) {
var stream = new Stream.Transform({objectMode: true});
function parsePath(path) {
var extname = Path.extname(path);
return {
dirname: Path.dirname(path),
basename: Path.basename(path, extname),
extname: extname
};
}
stream._transform = function(file, unused, callback) {
var parsedPath = parsePath(file.relative);
var path;
var type = typeof obj;
if (type === 'string' && obj !== '') {
path = obj;
} else if (type === 'function') {
obj(parsedPath);
path = Path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
} else if (type === 'object' && obj !== undefined && obj !== null) {
var dirname = 'dirname' in obj ? obj.dirname : parsedPath.dirname,
prefix = obj.prefix || '',
suffix = obj.suffix || '',
basename = 'basename' in obj ? obj.basename : parsedPath.basename,
extname = 'extname' in obj ? obj.extname : parsedPath.extname;
path = Path.join(dirname, prefix + basename + suffix + extname);
} else {
callback(new Error('Unsupported renaming parameter type supplied'), undefined);
return;
}
file.path = Path.join(file.base, path);
// Rename sourcemap if present
if (file.sourceMap) {
file.sourceMap.file = file.relative;
}
callback(null, file);
};
return stream;
}
module.exports = gulpRename;
|