Skip to content

Commit

Permalink
Replace wrench with fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornharrtell committed Mar 31, 2016
1 parent b7c89c9 commit 5ca4590
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
6 changes: 3 additions & 3 deletions lib/jsdoc/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var fs = require('fs');
var path = require('path');
var stream = require('stream');
var wrench = require('wrench');
var fse = require('fs-extra');

var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
var file;
Expand Down Expand Up @@ -91,7 +91,7 @@ exports.mkPath = function(_path) {
_path = _path.join('');
}

wrench.mkdirSyncRecursive(_path);
fse.mkdirsSync(_path);
};

// adapted from http://procbits.com/2011/11/15/synchronous-file-copy-in-node-js
Expand All @@ -106,7 +106,7 @@ exports.copyFileSync = function(inFile, outDir, fileName) {
var outFile = path.join( outDir, fileName || path.basename(inFile) );
var pos = 0;

wrench.mkdirSyncRecursive(outDir);
fse.mkdirsSync(outDir);
read = fs.openSync(inFile, 'r');
write = fs.openSync(outFile, 'w');

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"strip-json-comments": "~2.0.1",
"taffydb": "https://github.com/hegemonic/taffydb/tarball/7d100bcee0e997ee4977e273cdce60bd8933050e",
"underscore": "~1.8.3",
"wrench": "~1.5.9"
"fs-extra": "~0.26.7"
},
"devDependencies": {
"gulp": "~3.9.1",
Expand Down
28 changes: 14 additions & 14 deletions test/jasmine-jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ jasmine.executeSpecsInFolder = function(folder, done, opts) {
var jasmineEnv = jasmine.initialize(done, opts.verbose);

// Load the specs
specs.load(folder, fileMatcher, true);

var specsList = specs.getSpecs();
var filename;

// Add the specs to the context
for (var i = 0, len = specsList.length; i < len; ++i) {
filename = specsList[i];
require(filename.path().replace(/\\/g, '/')
.replace(new RegExp('^' + jsdoc.env.dirname + '/test'), './')
.replace(/\.\w+$/, ''));
}
specs.load(folder, fileMatcher, true, function() {
var specsList = specs.getSpecs();
var filename;

// Add the specs to the context
for (var i = 0, len = specsList.length; i < len; ++i) {
filename = specsList[i];
require(filename.path().replace(/\\/g, '/')
.replace(new RegExp('^' + jsdoc.env.dirname + '/test'), './')
.replace(/\.\w+$/, ''));
}

// Run Jasmine
jasmineEnv.execute();
// Run Jasmine
jasmineEnv.execute();
});
};

function now() {
Expand Down
25 changes: 16 additions & 9 deletions test/spec-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var fs = require('jsdoc/fs');
var path = require('jsdoc/path');
var runtime = require('jsdoc/util/runtime');
var wrench = require('wrench');
var fse = require('fs-extra');

var specs = [];
var finalSpecs = [];
Expand Down Expand Up @@ -75,18 +75,25 @@ function shouldLoad(file, matcher) {
return result;
}

exports.load = function(loadpath, matcher, clear) {
exports.load = function(loadpath, matcher, clear, callback) {
if (clear === true) {
clearSpecs();
}

var wannaBeSpecs = wrench.readdirSyncRecursive(loadpath);
for (var i = 0; i < wannaBeSpecs.length; i++) {
var file = path.join(loadpath, wannaBeSpecs[i]);
if ( shouldLoad(file, matcher) ) {
addSpec(file);
}
}
var wannaBeSpecs = [];
fse.walk(loadpath)
.on('data', function(spec) {
wannaBeSpecs.push(spec.path);
})
.on('end', function() {
for (var i = 0; i < wannaBeSpecs.length; i++) {
var file = wannaBeSpecs[i];
if ( shouldLoad(file, matcher) ) {
addSpec(file);
}
}
callback();
});
};

exports.getSpecs = function() {
Expand Down

0 comments on commit 5ca4590

Please sign in to comment.