Skip to content

Commit 8fb2947

Browse files
committed
Sorted file entries for examples based on type
1 parent 2fe3cb2 commit 8fb2947

File tree

3 files changed

+85
-64
lines changed

3 files changed

+85
-64
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

introToAngular/compileReadme.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,30 @@ function generateExampleJSON(){
7676

7777
}
7878

79+
// Computes the list of files for each example.
80+
// Sorts files by:
81+
// index.html > *.html > *.js > *.json > *
7982
function listFilesForExample(file){
8083
var path = snapshotsPath + file,
81-
files = fs.readdirSync(path);
82-
return _.difference(files, irrelevantFiles);
84+
allFiles = fs.readdirSync(path),
85+
files =_.difference(allFiles, irrelevantFiles);
86+
return _.sortBy(files, filePrecedence);
87+
}
88+
89+
function filePrecedence(name){
90+
var ext = name.substr(name.lastIndexOf('.'));
91+
92+
if(name === 'index.html'){
93+
return 0;
94+
} else if (ext === '.html') {
95+
return 1;
96+
} else if (ext === '.js') {
97+
return 2;
98+
} else if (ext === '.json') {
99+
return 3;
100+
} else {
101+
return 4;
102+
}
83103
}
84104

85105
function extractNumber(name){

0 commit comments

Comments
 (0)