-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement: default pattern #9
Conversation
僕のコミットをムダにしないために、いくつかレビューコメント残しておきます。 |
for (var i = 0; i < paths.length; ++i) { | ||
var dir = pather.dirname(paths[i]); | ||
var dirName = dir.split(pather.sep).pop(); | ||
if (dirName !== packageName && fs.existsSync(pather.join(dir, 'package.json'))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existsSync is deprecated near the future.
if the package.json is not found, you don't require in line 6.
so the check is meaningless.
EDIT: sorry, scratch that. I misunderstood this specification.
However existsSync is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
面倒なので日本語で。
v0.10とかだとaccessSyncもないから今のところはexsitsSyncでいいような気がしてきました。
真面目にやるならこうですかね。
var existsSync = fs.accessSync ? fs.accessSync : fs.existsSync;
// ...
if (dirName !== packageName && existsSync(pather.join(dir, 'package.json'))) {
// ...
}
see: nodejs/node#257
まぁまだiojsでもexistsSyncはdeprecatedにはなっていないので、参考までに。
typeof pkg.directories.test === 'string') { | ||
return normalizeDir(pkg.directories.test); | ||
} | ||
return "test/"; // default value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think default value should not define in this function.
- before
function getTestDirFromPkg(pkg) {
if (pkg &&
typeof pkg.directories === 'object' &&
typeof pkg.directories.test === 'string') {
return normalizeDir(pkg.directories.test);
}
return "test/";
}
- after
var defaultTestDir = "test/";
function getTestDirFromPkg(pkg) {
if (pkg &&
typeof pkg.directories === 'object' &&
typeof pkg.directories.test === 'string') {
return normalizeDir(pkg.directories.test);
}
return defaultTestDir;
}
var assert = require("assert"); | ||
var getTestDir = require("../lib/get-test-dir"); | ||
describe("get-test-dir-test", function () { | ||
context("when `pkg.directories.test` is not found", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test case when pkg.directories is undefined.
@yosuke-furukawa Thanks for review! I'v fixed. |
Thank you for the quick fixing!! |
ref #8
If the user didn't set
directories.test
, use'test/**/*.js'
as default pattern.