From a986df0fa7cecc3b373018af0b69b46246b7af83 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 12 Oct 2022 14:16:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dnodejs=2014.14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 17 +++++++---------- index.mjs | 17 +++++++---------- package.json | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 7e4d829..2a6df91 100644 --- a/index.js +++ b/index.js @@ -21,10 +21,7 @@ class Stats { } } -const VERSION = +process.versions.node - .split('.') - .slice(0, 2) - .join('.') +const VERSION = +process.versions.node.split('.').slice(0, 2).join('.') const EMPTY_STAT = new Stats() @@ -201,16 +198,16 @@ const Iofs = { */ rm(origin, debug) { try { - if (this.isdir(origin)) { - if (VERSION > 12.1) { - FS.rmdirSync(origin, { recursive: true }) - } else { + if (VERSION >= 14.14) { + FS.rmSync(origin, { recursive: true }) + } else { + if (this.isdir(origin)) { var list = this.ls(origin) list.forEach(it => this.rm(it)) FS.rmdirSync(origin) + } else { + FS.unlinkSync(origin) } - } else { - FS.unlinkSync(origin) } return true } catch (err) { diff --git a/index.mjs b/index.mjs index 2e3e0b5..f88e507 100644 --- a/index.mjs +++ b/index.mjs @@ -21,10 +21,7 @@ class STATS { } } -const VERSION = +process.versions.node - .split('.') - .slice(0, 2) - .join('.') +const VERSION = +process.versions.node.split('.').slice(0, 2).join('.') const EMPTY_STAT = new STATS() @@ -201,16 +198,16 @@ export default { */ rm(origin, debug) { try { - if (this.isdir(origin)) { - if (VERSION > 12.1) { - FS.rmdirSync(origin, { recursive: true }) - } else { + if (VERSION >= 14.14) { + FS.rmSync(origin, { recursive: true }) + } else { + if (this.isdir(origin)) { var list = this.ls(origin) list.forEach(it => this.rm(it)) FS.rmdirSync(origin) + } else { + FS.unlinkSync(origin) } - } else { - FS.unlinkSync(origin) } return true } catch (err) { diff --git a/package.json b/package.json index b0791d7..7d2a721 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,23 @@ { "name": "iofs", - "version": "1.5.2", + "version": "1.5.3", "description": "iofs是一个基于原生fs模块封装的工具, 旨在提供更加方便实用一些常用的API方法(同步), API习惯参考了bash shell。", "main": "index.js", + "exports": { + "require": "./index.js", + "import": "./index.mjs" + }, "repository": { "type": "git", "url": "https://github.com/bytedo/iofs.git" }, - "keywords": ["fivejs", "fs", "iofs", "fs.io", "file"], + "keywords": [ + "fivejs", + "fs", + "iofs", + "fs.io", + "file" + ], "author": "yutent", "license": "MIT" }