utils-1812b-11

1.0.0 • Public • Published

fs

赋值文件夹

const fs = require('fs');

function copyDir(d1, d2) {
    if (!fs.existsSync(d2)) {
        fs.mkdirSync(d2);
    }
    let arr = fs.readdirSync(d1);
    arr.forEach(item => {
        let dird1 = d1 + '/' + item;
        let dird2 = d2 + '/' + item;
        if (fs.statSync(dird1).isFile()) {
            fs.copyFileSync(dird1, dird2);
        } else {
            copyDir(dird1, dird2);
        }
    })
}
copyDir('deom', 'deom1');

Readme

Keywords

none

Package Sidebar

Install

npm i utils-1812b-11

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

1.17 kB

Total Files

3

Last publish

Collaborators

  • qwe896673315