assets-include
Advanced tools
Comparing version 0.3.1 to 0.5.0
@@ -0,1 +1,12 @@ | ||
0.5.0 / 2012-08-07 | ||
================== | ||
* Adds Windows support with all tests fixed. | ||
0.4.0 / 2012-08-03 | ||
================== | ||
* Fallback for path.existsSync in node 0.6.x. | ||
* Restricting support to node >= 0.6.0. | ||
0.3.1 / 2012-07-04 | ||
@@ -2,0 +13,0 @@ ================== |
var AssetsExpander = require('assets-expander'), | ||
fs = require('fs'), | ||
path = require('path'); | ||
path = require('path'), | ||
existsSync = fs.existsSync || path.existsSync; | ||
var isWindows = process.platform == 'win32'; | ||
var AssetsInclude = function(pathToConfig, options) { | ||
@@ -9,4 +12,4 @@ this.options = options; | ||
this.rootPath = process.cwd(); | ||
if (this.options.root.indexOf('/') > 0) | ||
if (this.options.root.indexOf(this.rootPath) != 0) | ||
this.options.root = path.normalize(path.join(this.rootPath, this.options.root)); | ||
@@ -16,3 +19,3 @@ | ||
var cacheFile = path.join(this.rootPath, path.dirname(pathToConfig), '.' + path.basename(pathToConfig) + '.json'); | ||
if (path.existsSync(cacheFile)) | ||
if (existsSync(cacheFile)) | ||
this.cacheInfo = JSON.parse(fs.readFileSync(cacheFile, 'utf8')); | ||
@@ -25,4 +28,3 @@ } | ||
var self = this, | ||
bundleInfo = this._bundleInfo(locator), | ||
asHTMLFragment = ''; | ||
bundleInfo = this._bundleInfo(locator); | ||
@@ -37,7 +39,10 @@ return this.list(locator) | ||
list: function(locator) { | ||
self = this, | ||
bundleInfo = this._bundleInfo(locator); | ||
var self = this, | ||
bundleInfo = this._bundleInfo(locator), | ||
es = function(pathWithStamp) { // escape slashes | ||
return isWindows ? pathWithStamp.replace(/\\/g, '/') : pathWithStamp; | ||
}; | ||
if (this.options.bundled) { | ||
return [self._assetPathWithStamp(self._bundledPath(bundleInfo), bundleInfo)]; | ||
return [es(self._assetPathWithStamp(self._bundledPath(bundleInfo), bundleInfo))]; | ||
} else { | ||
@@ -52,3 +57,3 @@ var expanderOptions = { | ||
.map(function(assetPath) { | ||
return self._assetPathWithStamp(assetPath, bundleInfo); | ||
return es(self._assetPathWithStamp(assetPath, bundleInfo)); | ||
}); | ||
@@ -85,3 +90,3 @@ } | ||
} else { | ||
var mtime = assetPath.indexOf('/') == 0 ? | ||
var mtime = assetPath.indexOf(this.rootPath) == 0 ? | ||
fs.statSync(assetPath).mtime.getTime() : | ||
@@ -88,0 +93,0 @@ fs.statSync(path.join(this.rootPath, assetPath)).mtime.getTime(); |
@@ -5,9 +5,6 @@ { | ||
"description": "Include assets into your views with ease (assets-packager compatible).", | ||
"version": "0.3.1", | ||
"version": "0.5.0", | ||
"repository": { | ||
"url": "" | ||
}, | ||
"engines": { | ||
"node": "~0.6" | ||
}, | ||
"bin": { | ||
@@ -17,3 +14,3 @@ "assetsinc": "./bin/assetsinc" | ||
"dependencies": { | ||
"assets-expander": "0.2.x", | ||
"assets-expander": "0.4.x", | ||
"optimist": "0.3.x" | ||
@@ -24,3 +21,5 @@ }, | ||
}, | ||
"optionalDependencies": {} | ||
"engines": { | ||
"node": ">=0.6.0" | ||
} | ||
} |
@@ -5,5 +5,10 @@ var vows = require('vows'), | ||
var isWindows = process.platform == 'win32'; | ||
var binaryContext = function(options, context) { | ||
context.topic = function() { | ||
exec("cd test; ../bin/assetsinc " + options, this.callback); | ||
if (isWindows) | ||
exec("cd test & node ..\\bin\\assetsinc " + options, this.callback); | ||
else | ||
exec("cd test; ../bin/assetsinc " + options, this.callback); | ||
}; | ||
@@ -10,0 +15,0 @@ return context; |
var vows = require('vows'), | ||
assert = require('assert'), | ||
path = require('path'), | ||
AssetsInclude = require('../index'); | ||
@@ -9,5 +10,5 @@ | ||
if (!options.root) | ||
options.root = 'test/data/public'; | ||
options.root = path.join('test', 'data', 'public'); | ||
return new AssetsInclude('test/data/config.yml', options); | ||
return new AssetsInclude(path.join('test', 'data', 'config.yml'), options); | ||
}; | ||
@@ -109,3 +110,3 @@ return definition; | ||
} | ||
}, { root: process.cwd() + '/test/data/public' }) | ||
}, { root: path.join(process.cwd(), 'test', 'data', 'public') }) | ||
} | ||
@@ -112,0 +113,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
21856
27
395
1
+ Addedassets-expander@0.4.1(transitive)
- Removedassets-expander@0.2.3(transitive)
- Removedrightjs@2.2.3(transitive)
Updatedassets-expander@0.4.x