Comparing version 0.2.1 to 0.2.2
@@ -11,4 +11,6 @@ var path = require( 'path' ), | ||
var Node = function ( file ) { | ||
var Node = function ( file, content ) { | ||
this.file = path.resolve( file ); | ||
this.content = content; | ||
this.sourcesContentByPath = {}; | ||
@@ -21,3 +23,11 @@ }; | ||
return sander.readFile( this.file ).then( String ).then( function ( content ) { | ||
function getContent () { | ||
if ( !self.content ) { | ||
return sander.readFile( self.file ).then( String ); | ||
} | ||
return sander.Promise.resolve( self.content ); | ||
} | ||
return getContent().then( function ( content ) { | ||
var url; | ||
@@ -35,9 +45,10 @@ | ||
return getMapFromUrl( url, self.file ).then( function ( map ) { | ||
var promises; | ||
var promises, sourcesContent; | ||
self.map = map; | ||
self.mappings = decodeMappings( map.mappings ); | ||
sourcesContent = map.sourcesContent || []; | ||
self.sources = map.sources.map( function ( source ) { | ||
return new Node( resolveSourcePath( self, source ) ); | ||
self.sources = map.sources.map( function ( source, i ) { | ||
return new Node( resolveSourcePath( self, source ), sourcesContent[i] ); | ||
}); | ||
@@ -65,5 +76,8 @@ | ||
_loadSync: function () { | ||
var self = this, url, map; | ||
var self = this, url, map, sourcesContent; | ||
this.content = sander.readFileSync( this.file ).toString(); | ||
if ( !this.content ) { | ||
this.content = sander.readFileSync( this.file ).toString(); | ||
} | ||
this.lines = this.content.split( '\n' ); | ||
@@ -76,7 +90,8 @@ | ||
} else { | ||
self.map = getMapFromUrl( url, this.file, true ); | ||
self.mappings = decodeMappings( self.map.mappings ); | ||
self.map = map = getMapFromUrl( url, this.file, true ); | ||
self.mappings = decodeMappings( map.mappings ); | ||
sourcesContent = map.sourcesContent || []; | ||
self.sources = self.map.sources.map( function ( source ) { | ||
var node = new Node( resolveSourcePath( self, source ) ); | ||
self.sources = map.sources.map( function ( source, i) { | ||
var node = new Node( resolveSourcePath( self, source ), sourcesContent[i] ); | ||
node._loadSync(); | ||
@@ -214,2 +229,7 @@ | ||
if ( typeof dest !== 'string' ) { | ||
dest = this.file; | ||
options = dest; | ||
} | ||
options = options || {}; | ||
@@ -216,0 +236,0 @@ dest = path.resolve( dest ); |
{ | ||
"name": "sorcery", | ||
"description": "Resolve a chain of sourcemaps back to the original source", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Rich Harris", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/Rich-Harris/sorcery", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18531
436