Skip to content

Commit

Permalink
Fix createIndex script for running on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth G. Franqueiro committed Sep 25, 2015
1 parent 5fc2591 commit 56c47c5
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 334 deletions.
10 changes: 5 additions & 5 deletions test/data/createIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var fs = require('fs'),
path = require('path'),
list = [], // stores list of files as they are scanned
titleRx = /<title>([^<]+)/, // RegExp for scanning title tag
internDirRx = /test\/intern\//, // RegExp for paths under the intern folder
internDirRx = /test[\/\\]intern[\/\\]/, // RegExp for paths under the intern folder
testDir = path.join(__dirname, '..'),
filename = path.join(__dirname, 'index.json');

Expand All @@ -15,7 +15,7 @@ function populateList(subdir) {
// the initial call should not specify an argument.

var dir = path.join(testDir, subdir),
files = fs.readdirSync(dir),
files = fs.readdirSync(dir).sort(),
i, len, file, match;

for (i = 0, len = files.length; i < len; i++) {
Expand All @@ -24,7 +24,7 @@ function populateList(subdir) {
match = titleRx.exec(fs.readFileSync(path.join(dir, file)));
list.push({
name: file, // filename only, for display purposes
url: path.join(subdir, file), // relative to test folder, serves as ID
url: (subdir ? subdir + '/' : '') + file, // relative to test folder, serves as ID
title: match ? match[1] : '',
parent: subdir || ''
});
Expand All @@ -33,7 +33,7 @@ function populateList(subdir) {
// Subdirectory found; add entry and recurse
list.push({
name: file,
url: path.join(subdir, file),
url: (subdir ? subdir + '/' : '') + file,
parent: subdir || ''
});
populateList(path.join(subdir, file));
Expand All @@ -42,4 +42,4 @@ function populateList(subdir) {
}

populateList('');
fs.writeFileSync(filename, JSON.stringify(list, null, 4));
fs.writeFileSync(filename, JSON.stringify(list, null, '\t') + '\n');
Loading

0 comments on commit 56c47c5

Please sign in to comment.