New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-source-map

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-source-map - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

.mailmap

104

index.js

@@ -9,3 +9,3 @@ 'use strict';

function _genMkdirOrProcess(process) {
function _genMkdirOrProcess(destDir, process) {
return function(relativePath) {

@@ -25,64 +25,58 @@ if (relativePath.slice(-1) === '/') {

function SourceMapInliner(inputTree) {
if (!(this instanceof SourceMapInliner)) return new SourceMapInliner(inputTree);
this.inputTree = inputTree;
}
SourceMapInliner.prototype = Object.create(CachingWriter.prototype);
SourceMapInliner.prototype.constructor = SourceMapInliner;
SourceMapInliner.prototype.updateCache = function(srcDir, destDir) {
walkSync(srcDir).forEach(_genMkdirOrProcess(function(relativePath) {
if (_isSourceMappableFile(relativePath)) {
var srcPath = path.join(srcDir, relativePath);
var destPath = path.join(destDir, relativePath);
var srcCode = fs.readFileSync(srcPath, {encoding: 'utf-8'});
var smap = convert.fromMapFileSource(srcCode, srcDir);
if (smap !== null && typeof smap['sourcemap'] !== 'undefined') {
if (typeof smap.getProperty('sourcesContent') === 'undefined' && typeof smap.getProperty('sources') !== 'undefined') {
var contents = smap.getProperty('sources').map(function(spath) {
return fs.readFileSync(path.join(srcDir, spath), {encoding: 'utf-8'});
});
smap = smap.setProperty('sourcesContent', contents);
var SourceMapProcessor = CachingWriter.extend({
updateCache: function(srcPaths, destDir) {
var self = this;
srcPaths.forEach(function(srcDir) {
walkSync(srcDir).forEach(_genMkdirOrProcess(destDir, function(relativePath) {
if (_isSourceMappableFile(relativePath)) {
var srcPath = path.join(srcDir, relativePath);
var destPath = path.join(destDir, relativePath);
var srcCode = fs.readFileSync(srcPath, {encoding: 'utf-8'});
self.processCode(srcCode, srcDir, destPath, relativePath);
}
var comment = smap.toComment();
if (destPath.slice(-4) === '.css') {
comment = comment.replace(/^\/\//, '/*') + ' */';
}
fs.writeFileSync(destPath, convert.removeMapFileComments(srcCode) + '\n' + comment);
} else {
fs.writeFileSync(destPath, srcCode);
}));
});
}
});
var SourceMapInliner = SourceMapProcessor.extend({
processCode: function(srcCode, srcDir, destPath, relativePath) {
var smap = convert.fromMapFileSource(srcCode, srcDir);
if (smap !== null && typeof smap['sourcemap'] !== 'undefined') {
if (typeof smap.getProperty('sourcesContent') === 'undefined' && typeof smap.getProperty('sources') !== 'undefined') {
var contents = smap.getProperty('sources').map(function(spath) {
return fs.readFileSync(path.join(srcDir, spath), {encoding: 'utf-8'});
});
smap = smap.setProperty('sourcesContent', contents);
}
var comment = smap.toComment();
if (destPath.slice(-4) === '.css') {
comment = comment.replace(/^\/\//, '/*') + ' */';
}
fs.writeFileSync(destPath, convert.removeMapFileComments(srcCode) + '\n' + comment);
} else {
fs.writeFileSync(destPath, srcCode);
}
}));
}
}
});
function SourceMapExtractor(inputTree) {
if (!(this instanceof SourceMapExtractor)) return new SourceMapExtractor(inputTree);
this.inputTree = inputTree;
}
SourceMapExtractor.prototype = Object.create(CachingWriter.prototype);
SourceMapExtractor.prototype.constructor = SourceMapExtractor;
SourceMapExtractor.prototype.updateCache = function(srcDir, destDir) {
walkSync(srcDir).forEach(_genMkdirOrProcess(function(relativePath) {
if (_isSourceMappableFile(relativePath)) {
var srcPath = path.join(srcDir, relativePath);
var destPath = path.join(destDir, relativePath);
var srcCode = fs.readFileSync(srcPath, {encoding: 'utf-8'});
var smap = convert.fromComment(srcCode, srcDir);
if (smap !== null) {
var comment = '//# sourceMappingURL=' + relativePath + '.map';
if (destPath.slice(-4) === '.css') {
comment = '/*# sourceMappingURL=' + relativePath + '.map */';
}
fs.writeFileSync(destPath, convert.removeComments(srcCode) + '\n' + comment);
fs.writeFileSync(destPath + '.map', smap.toJSON());
} else {
fs.writeFileSync(destPath, srcCode);
var SourceMapExtractor = SourceMapProcessor.extend({
processCode: function(srcCode, srcDir, destPath, relativePath) {
var smap = convert.fromComment(srcCode, srcDir);
if (smap !== null) {
var comment = '//# sourceMappingURL=' + relativePath + '.map';
if (destPath.slice(-4) === '.css') {
comment = '/*# sourceMappingURL=' + relativePath + '.map */';
}
fs.writeFileSync(destPath, convert.removeComments(srcCode) + '\n' + comment);
fs.writeFileSync(destPath + '.map', smap.toJSON());
} else {
fs.writeFileSync(destPath, srcCode);
}
}));
}
}
});
module.exports = {
inline: SourceMapInliner,
extract: SourceMapExtractor
inline: function(t, o) { return new SourceMapInliner(t, o); },
extract: function(t, o) { return new SourceMapExtractor(t, o); }
}
{
"name": "broccoli-source-map",
"description": "A Broccoli plugin for inlining or extracting sourcemaps",
"version": "0.1.2",
"author": "Greg V <floatboth@me.com>",
"version": "0.2.0",
"author": "Greg V <greg@unrelenting.technology>",
"engines": {

@@ -15,7 +15,12 @@ "node": "*"

"dependencies": {
"broccoli-caching-writer": "^0.3.1",
"broccoli-caching-writer": "^0.5.2",
"mkdirp": "^0.5.0",
"walk-sync": "^0.1.2",
"convert-source-map": "^0.3.4"
"convert-source-map": "^0.4.1"
},
"devDependencies": {
"mocha": "^2.1.0",
"broccoli": "^0.13.0",
"expect.js": "^0.3.1"
},
"repository": {

@@ -22,0 +27,0 @@ "type": "git",

@@ -5,3 +5,3 @@ # broccoli-source-map [![npm version](https://img.shields.io/npm/v/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![npm downloads](https://img.shields.io/npm/dm/broccoli-source-map.svg?style=flat)](https://www.npmjs.org/package/broccoli-source-map) [![Dependency Status](https://img.shields.io/gemnasium/myfreeweb/broccoli-source-map.svg?style=flat)](https://gemnasium.com/myfreeweb/broccoli-source-map) [![WTFPL](https://img.shields.io/badge/license-WTFPL-brightgreen.svg?style=flat)](https://www.tldrlegal.com/l/wtfpl)

[Broccoli]: https://github.com/joliss/broccoli
[Broccoli]: https://github.com/broccolijs/broccoli
[JavaScript source maps]: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/

@@ -41,5 +41,5 @@ [convert-source-map]: https://www.npmjs.org/package/convert-source-map

Copyright © 2014 [myfreeweb](https://github.com/myfreeweb)
Copyright © 2014-2015 Greg V <greg@unrelenting.technology>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the COPYING file for more details.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc