Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- tests

  • Loading branch information...
commit b32105a311a3293679dace4100af4c6ea956cf1f 1 parent 3a36a1a
@SamuraiJack SamuraiJack authored
View
2  node_modules/librarian/lib/File.js
@@ -24,8 +24,6 @@ module.exports = Joose.Class({
methods : {
_buildRawDependencies : function () {
- //console.log("Raw deps of %s found: %s", this.name, detective(this.librarian.getContentOf(this.name), 'utf8'))
-
return detective(this.librarian.getContentOf(this.name), 'utf8')
},
View
10 node_modules/librarian/lib/Librarian.js
@@ -80,8 +80,6 @@ module.exports = Joose.Class({
getContentOf : function (fileName) {
if (fileName instanceof File) fileName = fileName.name
- //console.log('GET CONTENT OF %s', fileName)
-
return fs.readFileSync(path.join(this.root, fileName), 'utf8')
},
@@ -92,16 +90,12 @@ module.exports = Joose.Class({
fileExists : function (fileName) {
- //console.log('CHECKING FILE %s', fileName)
-
try {
var stat = fs.statSync(path.join(this.root, fileName))
return stat.isFile()
} catch (e) {
- //console.log('FILE NOT EXIST %s', fileName)
-
return false
}
},
@@ -122,7 +116,7 @@ module.exports = Joose.Class({
wrap : function (file) {
return this.template().render({
- content : this.getContentOf(file.name),
+ content : this.getContentOf(file),
includeJooseCompat : this.includeJooseCompat,
@@ -144,8 +138,6 @@ module.exports = Joose.Class({
return me.getFile(path.relative(me.root, path.resolve(file)))
})
-// console.log('WRITE BUNDLE: requirements: %s, files: %s, scripts: %s', requires, files, scripts)
-
Joose.A.each(scripts.concat(requirements), function (file) {
allDeps[ file.name ] = file
View
49 node_modules/librarian/t/010_librarian.t.js
@@ -49,29 +49,40 @@ StartTest(function (t) {
}, 'Correctly resolved jojo')
+ t.is(librarian.resolve('./lib/Backend', '.'), 'lib/Backend.js', 'Correct resolve #1, path normalized')
+ t.is(librarian.resolve('./Backend', 'lib'), 'lib/Backend.js', 'Correct resolve #2, path normalized')
+ t.is(librarian.resolve('./Cool.js', './lib/Backend'), 'lib/Backend/Cool.js', 'Correct resolve #3, path normalized')
+
+ t.is(librarian.resolve('../Backend/Cool', './lib/Backend'), 'lib/Backend/Cool.js', 'Correct resolve #4, path normalized')
+ t.is(librarian.resolve('../node_modules/../node_modules/cujo', 'lib'), 'node_modules/cujo/index.js', 'Correct resolve #5, path normalized')
+ t.is(librarian.resolve('../node_modules/../node_modules/cujo/./', 'lib/././../lib'), 'node_modules/cujo/index.js', 'Correct resolve #6, path normalized')
+
//==================================================================================================================================================================================
t.diag("In depth dependencies")
-// var realDeps = file.getInDepthDependencies()
-// var deps = {}
-//
-// Joose.O.each(deps, function (value, name) {
-// t.isa_ok(value, File, 'All dependencies are files')
-//
-// deps[ name ] = true
-// })
-//
-// t.isDeeply(deps, {
-//
-// 'node_modules/jojo/super/cool.js' : true,
-// 'node_modules/jojo/package.json' : true,
-// 'node_modules/joose/index.js' : true,
-// 'lib/Backend.js' : true,
-// 'node_modules/jobo/index.js' : true,
-// 'node_modules/cujo/index.js' : true
-//
-// }, 'Correct dependencies for cool backend found')
+ t.isDeeply(file.getInDepthDependencies(), {
+
+ 'node_modules/jojo/super/cool.js' : librarian.getFile('node_modules/jojo/super/cool.js'),
+ 'node_modules/jojo/package.json' : librarian.getFile('node_modules/jojo/package.json'),
+ 'node_modules/joose/index.js' : librarian.getFile('node_modules/joose/index.js'),
+ 'lib/Backend.js' : librarian.getFile('lib/Backend.js'),
+ 'node_modules/jobo/index.js' : librarian.getFile('node_modules/jobo/index.js'),
+ 'node_modules/cujo/index.js' : librarian.getFile('node_modules/cujo/index.js')
+
+ }, 'Correct dependencies for cool backend found')
+
+ t.isDeeply(librarian.getFile('node_modules/joose/index.js').getInDepthDependencies(), {}, 'Correct dependencies for joose found')
+
+ t.isDeeply(librarian.getFile('lib/Backend.js').getInDepthDependencies(), {
+
+ 'node_modules/joose/index.js' : librarian.getFile('node_modules/joose/index.js'),
+ 'node_modules/jobo/index.js' : librarian.getFile('node_modules/jobo/index.js'),
+ 'node_modules/cujo/index.js' : librarian.getFile('node_modules/cujo/index.js')
+
+ }, 'Correct dependencies for backend found')
+
+
t.done()
View
18 node_modules/librarian/util/module_resolver.js
@@ -31,8 +31,6 @@ var ModuleResolver = {
requireStr = requireStr.replace(/\/+$/, '')
requireStr = this.cleanupPath(requireStr)
- //console.log("AS DIR: %s", requireStr);
-
var packageFileName = requireStr + '/package.json'
if (this.fileExists(packageFileName)) {
@@ -58,17 +56,9 @@ var ModuleResolver = {
resolveAsFile : function (requireStr) {
requireStr = this.cleanupPath(requireStr)
- //console.log("AS FILE: %s", requireStr);
-
- if (this.fileExists(requireStr)) {
- //console.log("resolved to: %s", requireStr);
- return requireStr
- }
+ if (this.fileExists(requireStr)) return requireStr
- if (this.fileExists(requireStr + '.js')) {
- //console.log("resolved to: %s", requireStr + '.js');
- return requireStr + '.js'
- }
+ if (this.fileExists(requireStr + '.js')) return requireStr + '.js'
return null
},
@@ -93,8 +83,6 @@ var ModuleResolver = {
dirs.push('node_modules')
- //console.log('FOUND DIRS: %s', dirs)
-
for (var i = 0; i < dirs.length; i++) {
var resolved = this.resolveAsDir(dirs[ i ] + '/' + requireStr, dependencies)
@@ -112,8 +100,6 @@ var ModuleResolver = {
// when such additional dependency will be discovered the role will "register" it with `addAdditionalDependency`
// call, passing the `dependencies` argument and file name to it
resolve : function (requireStr, baseDir, dependencies) {
- //console.log("RESOLVE: %s, %s", requireStr, baseDir);
-
if (this.coreModules[ requireStr ]) return this.getCoreModule(requireStr)
baseDir = (baseDir || '.').replace(/\/+$/, '')
Please sign in to comment.
Something went wrong with that request. Please try again.