Created
March 2, 2019 15:00
-
-
Save lqqyt2423/11902f190eb63e6beb6004b2cab37074 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
// 删除文件 | |
const fs = require('fs'); | |
const path = require('path'); | |
const { log } = console; | |
const cwd = process.cwd(); | |
function eachDir (dir) { | |
const files = fs.readdirSync(dir, { withFileTypes: true }); | |
files.forEach(f => { | |
const name = f.name; | |
const fullname = path.join(dir, name); | |
console.log(fullname); | |
if (f.isDirectory()) { | |
eachDir(fullname); | |
return; | |
} | |
// rm .out | |
if (/\.out$/.test(name)) { | |
log('rm:', fullname); | |
fs.unlinkSync(fullname); | |
return; | |
} | |
// rm 二进制 | |
if (!/.+\./.test(name)) { | |
log('rm:', fullname); | |
fs.unlinkSync(fullname); | |
return; | |
} | |
}); | |
} | |
eachDir(cwd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment