mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Don't shell out for find
This commit is contained in:
@@ -466,6 +466,51 @@ files.cp_r = function (from, to, options) {
|
||||
});
|
||||
};
|
||||
|
||||
// Get every path in dir recursively
|
||||
files.getPathsInDir = function (dir, options) {
|
||||
if (! files.exists(dir)) {
|
||||
// There are no paths in this dir, so don't do anything
|
||||
return;
|
||||
}
|
||||
|
||||
var oldCwd = process.cwd();
|
||||
|
||||
var cwd = options && options.cwd;
|
||||
if (cwd) {
|
||||
if (! files.exists(cwd)) {
|
||||
throw new Error("Specified current working directory doesn't exist:" +
|
||||
cwd);
|
||||
}
|
||||
|
||||
process.chdir(cwd);
|
||||
}
|
||||
|
||||
var output = [];
|
||||
|
||||
_.each(files.readdir(dir), function (entry) {
|
||||
var newPath = files.pathJoin(dir, entry);
|
||||
output.push(newPath);
|
||||
|
||||
if (files.stat(newPath).isDirectory()) {
|
||||
output = output.concat(files.getPathsInDir(newPath));
|
||||
}
|
||||
});
|
||||
|
||||
process.chdir(oldCwd);
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
files.findPathsWithRegex = function (dir, regex, options) {
|
||||
var allPaths = files.getPathsInDir(dir, {
|
||||
cwd: options.cwd
|
||||
});
|
||||
|
||||
return _.filter(allPaths, function (path) {
|
||||
return path.match(regex);
|
||||
});
|
||||
};
|
||||
|
||||
// Copies a file, which is expected to exist. Parent directories of "to" do not
|
||||
// have to exist. Treats symbolic links transparently (copies the contents, not
|
||||
// the link itself, and it's an error if the link doesn't point to a file).
|
||||
|
||||
@@ -497,17 +497,15 @@ var installNpmModule = function (name, version, dir) {
|
||||
if (process.platform !== "win32") {
|
||||
// If we are on a unixy file system, we should not build a package that
|
||||
// can't be used on Windows.
|
||||
var output = utils.execFileSync("bash", ["-c", "find . | grep ':'"],
|
||||
{cwd: files.pathJoin(dir, "node_modules", name)});
|
||||
|
||||
console.log(files.pathJoin(dir, name));
|
||||
var pathsWithColons = files.findPathsWithRegex(".", new RegExp(":"),
|
||||
{ cwd: dir });
|
||||
|
||||
if (output.success) {
|
||||
var lines = output.stdout.split("\n");
|
||||
|
||||
var firstTen = lines.slice(0, 10);
|
||||
if (lines.length > 10) {
|
||||
firstTen.push("... " + (lines.length - 10) + " paths omitted.");
|
||||
if (pathsWithColons.length) {
|
||||
var firstTen = pathsWithColons.slice(0, 10);
|
||||
if (pathsWithColons.length > 10) {
|
||||
firstTen.push("... " + (pathsWithColons.length - 10) +
|
||||
" paths omitted.");
|
||||
}
|
||||
|
||||
buildmessage.error(
|
||||
|
||||
Reference in New Issue
Block a user