Skip to content

Commit c96abaf

Browse files
TheCodeDestroyerandyperlitch
authored andcommitted
Added npm v3 support when looking for flattened js libs (#80)
* Added idea to .gitignore * Added npm v3 support when looking for flattened js libs
1 parent 2bbe06d commit c96abaf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Directories
22
.DS_Store
33
.tmp
4+
.idea
45
node_modules
56
bower_components
67
dist

index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var setup = {sections: {}, pages: [], apis: {}};
2121
var fakeDest = '_FAKE_DEST_';
2222
var templates = path.resolve(__dirname, 'src/templates');
2323
var nodeModules = path.resolve(__dirname, 'node_modules');
24+
var flattenedNodeModules = path.resolve(__dirname, '../');
2425

2526
function copyTemplates() {
2627
return function () {
@@ -122,7 +123,16 @@ function processDoc(opts) {
122123
//Sets default script paths
123124
function joinNodeModules(jsPaths){
124125
_.each(jsPaths, function(jsPath){
125-
defaultScripts.push(path.join(nodeModules, jsPath));
126+
var libPath = path.join(nodeModules, jsPath),
127+
flattenedLibPath = path.join(flattenedNodeModules, jsPath);
128+
129+
if (fs.existsSync(libPath)) {
130+
defaultScripts.push(libPath);
131+
} else if (fs.existsSync(flattenedLibPath)) {
132+
defaultScripts.push(flattenedLibPath);
133+
} else {
134+
console.error('Could not find ' + jsPath);
135+
}
126136
});
127137
}
128138
//Iterate and checks to join paths

0 commit comments

Comments
 (0)