現在、Windowsの特定のフォルダにあるいくつかのファイルをnode
とgrunt
で検索しようとしています。Node.jsでdirのファイルを検索する
私はJSON
ファイルとディレクトリを読み出す機能を持っていますが、問題は、私はタスクを実行すると、ファイルを読み込むためのコードが何もしないということで、完璧なものgrunt task
実行上の他のすべてgrunt task
を持っています、 でもあの。パスの参照が正しいかどうかはわかりませんが、path.normalize()
も使用しており、エラーは発生しません。
これは、コードのスニペットです:
..// Some other code
var fs = require('fs'),
path = require("path");
grunt.registerTask('separate', function() {
var filePath = path.normalize("C:\Users\jbernhardt\Desktop\testkeeper\jenkinsReports");
fs.readdir(filePath, function(err, filenames) {
//This log doesn't show as it the function is not running
grunt.log.writeln("Testing");
if (err) {
grunt.log.writeln("Error");
return;
}
filenames.forEach(function(filename){
grunt.log.writeln("Testing");
});
});
...//Some more code below for the same task
}
私は、タスクを実行すると、コードのこのスニペットはスキップされている理由、誰もがアイデアを持っていますか?私はおそらくいくつかの基本的なものを見逃す可能性があります。ありがとう!
スラッシュがパス名をエスケープしています –
"C:\ Users \\ ..."または "C:/ Users /"を使用 – Draykos