/usr/lib/nodejs/grunt-babel/tasks/babel.js is in node-grunt-babel 7.0.0-3.
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 | 'use strict';
var path = require('path');
var babel = require('babel-core');
module.exports = function (grunt) {
grunt.registerMultiTask('babel', 'Use next generation JavaScript, today', function () {
var options = this.options();
this.files.forEach(function (el) {
delete options.filename;
delete options.filenameRelative;
options.sourceFileName = path.relative(path.dirname(el.dest), el.src[0]);
if (process.platform === 'win32') {
options.sourceFileName = options.sourceFileName.replace(/\\/g, '/');
}
options.sourceMapTarget = path.basename(el.dest);
var res = babel.transformFileSync(el.src[0], options);
var sourceMappingURL = '';
if (res.map) {
sourceMappingURL = '\n//# sourceMappingURL=' + path.basename(el.dest) + '.map';
}
grunt.file.write(el.dest, res.code + sourceMappingURL + '\n');
if (res.map) {
grunt.file.write(el.dest + '.map', JSON.stringify(res.map));
}
});
});
};
|