Socket
Socket
Sign inDemoInstall

yu-node

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yu-node - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

3

index.d.ts

@@ -5,2 +5,3 @@ // emptyDir,rmDir,getAllFiles,request,session,token

declare function rmDir(dirPath:string):boolean;
declare function copyDir(source:string,dest:string):void;
declare function getAllFiles(dirPath:string, ext?:string ,recursion?:boolean):string[];

@@ -11,2 +12,2 @@ declare function request(url:string,options:Object):Promise<Object>;

export { emptyDir,rmDir,getAllFiles,request,session,token };
export { emptyDir,rmDir,copyDir,getAllFiles,request,session,token };

@@ -1,2 +0,2 @@

const { emptyDir,rmDir } = require('./lib/handleDir.js');
const { emptyDir,rmDir,copyDir } = require('./lib/handleDir.js');
const { getAllFiles } = require('./lib/getAllFiles.js');

@@ -7,2 +7,2 @@ const request = require('./lib/request.js');

module.exports = Object.freeze({ emptyDir,rmDir,getAllFiles,request,session,token });
module.exports = Object.freeze({ emptyDir,rmDir,copyDir,getAllFiles,request,session,token });
const fs = require('fs');
const path = require('path');
const { getAllFiles } = require('./getAllFiles.js');
function emptyDir(dirPath){
function empty(dirPath){

@@ -16,3 +17,3 @@ const files = fs.readdirSync(dirPath, {withFileTypes:true});

}else{
emptyDir(child);
empty(child);
fs.rmdirSync(child);

@@ -23,17 +24,33 @@ }

exports.emptyDir = dirPath => {
function emptyDir(dirPath){
const bool = fs.existsSync(dirPath); //判断目录是否存在
if(!bool) return;
emptyDir(dirPath); //清空目录的子孙目录和所有文件
empty(dirPath); //清空目录的子孙目录和所有文件
return true;
};
exports.rmDir = dirPath => {
function rmDir(dirPath){
const bool = fs.existsSync(dirPath); //判断目录是否存在
if(!bool) return;
emptyDir(dirPath); //清空目录的子孙目录和所有文件
empty(dirPath); //清空目录的子孙目录和所有文件
fs.rmdirSync(dirPath); //删除本目录
return true;
}
function copyDir(source,dest){
source = path.resolve(source);
dest = path.resolve(dest);
let files = getAllFiles(source);
files.forEach(file=>{
let newPath = file.replace(source,dest);
const pathO = path.parse(newPath);
fs.mkdirSync(pathO.dir,{ recursive:true });
let rStream = fs.ReadStream(file);
let wStream = fs.WriteStream(newPath);
rStream.pipe(wStream);
});
}
module.exports = { emptyDir,rmDir,copyDir };
{
"name": "yu-node",
"version": "1.1.3",
"version": "1.1.4",
"description": "仅用于node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc