//showFile -src
let argv = process.argv[2].slice(1);
const path = require('path');
const fs = require('fs');
//__dirname:当前所在js文件的绝对路径
//process.cwd():小黑板打开的绝对路径
let url = path.join(process.cwd(),argv); //拼接路径
function read(url){
// console.log(__dirname);
// console.log("process",process.cwd())
if(fs.existsSync(url)){
//1.先读取目录
letlist = fs.readdirSync(url); //[css,index.html]
list.forEach(file=> {
letcurUrl =path.join(url,file);
//2.判断当前路径是文件还是文件夹
if(fs.statSync(curUrl).isDirectory()){
console.log(file)
//是文件夹
read(curUrl)
}else{
//是文件
console.log(file)
}
})
}else{
console.log("当前路径不合法")
}
}
read(url)