builder-amd-css
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -36,5 +36,4 @@ define(['require', './normalize'], function(req, normalize) { | ||
function loadFile(path) { | ||
if ( config.asReference && config.asReference.files ) { | ||
var files = config.asReference.files; | ||
return files[ path.replace( /^\//, "" ) ]; | ||
if ( config.asReference && config.asReference.loadFile ) { | ||
return config.asReference.loadFile( path ); | ||
} else if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) { | ||
@@ -71,4 +70,4 @@ var fs = require.nodeRequire('fs'); | ||
function saveFile(path, data) { | ||
if ( config.asReference && config.asReference.files ) { | ||
config.asReference.saveFile( path.replace( /^\//, "" ), data ); | ||
if ( config.asReference && config.asReference.saveFile ) { | ||
config.asReference.saveFile( path, data ); | ||
} else if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) { | ||
@@ -75,0 +74,0 @@ var fs = require.nodeRequire('fs'); |
11
index.js
@@ -37,5 +37,8 @@ var mutex, requireCssFiles, | ||
files[ filepath ] = requireCssFiles[ filepath ]; | ||
}); | ||
function normalizePath( _path ) { | ||
return path.normalize( _path ).replace( /^\//, "" ); | ||
} | ||
config = util._extend( {}, config ); | ||
@@ -50,5 +53,9 @@ config.appDir = config.appDir || "."; | ||
config.asReference = { | ||
files: files, | ||
saveFile: function( path, data ) { | ||
path = normalizePath( path ); | ||
files[ path ] = data; | ||
}, | ||
loadFile: function( path ) { | ||
path = normalizePath( path ); | ||
return files[ path ]; | ||
} | ||
@@ -55,0 +62,0 @@ }; |
{ | ||
"name": "builder-amd-css", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -67,1 +67,24 @@ var files, | ||
}); | ||
describe( "Using appDir and CSSes located in a different subdir", function() { | ||
var css, files; | ||
files = { | ||
"a/foo.js": fs.readFileSync( __dirname + "/fixtures/css-elsewhere/a/foo.js" ), | ||
"a/bar.js": fs.readFileSync( __dirname + "/fixtures/css-elsewhere/a/bar.js" ), | ||
"b/foo.css": fs.readFileSync( __dirname + "/fixtures/css-elsewhere/b/foo.css" ), | ||
"b/bar.css": fs.readFileSync( __dirname + "/fixtures/css-elsewhere/b/bar.css" ), | ||
}; | ||
before(function( done ) { | ||
AmdCssBuilder( files, { appDir: "a", include: [ "foo" ] }, function( error, _css ) { | ||
css = _css; | ||
done( error ); | ||
}); | ||
}); | ||
it( "should work just fine", function() { | ||
expect( css ).to.equal( ".foo {}\n.bar {}\n" ); | ||
}); | ||
}); |
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
38575
27
660