6 - Make it Modular
// 主程式,要載入 filter 的模組
var filterFn = require( './6-myModule.js' )
var dir = process.argv[2]
var filterStr = process.argv[3]
// 執行 filterFn 函式
filterFn ( dir, filterStr, function ( err, list ) {
// 報錯
if (err)
return console.error( "There was an error:", err )
// 列印符合的篩選檔案
list.forEach ( function (file) {
console.log(file)
})
}
)Last updated