修复系统目录

This commit is contained in:
Titor 2021-02-10 20:25:52 +08:00
parent d5cedac3ff
commit 257fc2a909
2 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.file = void 0;
var fs_1 = require("fs");
var path_1 = require("path");
/**
* 文件操作类
* @description 更加语义化的简便文件操作
@ -19,9 +20,9 @@ var file = /** @class */ (function () {
*/
file.createPath = function (filePath) {
// 获取完整目录(去除最后一位的文件字段)
var dir = filePath.substring(0, filePath.lastIndexOf("/"));
var dir = filePath.substring(0, filePath.lastIndexOf(path_1.sep));
if (dir == "" || dir == null)
dir = "./"; // 不写目录名 => 根目录
dir = "." + path_1.sep; // 不写目录名 => 根目录
// 文件夹不存在
if (!fs_1.existsSync(dir)) {
var actionNotice = fs_1.mkdirSync(dir, { recursive: true });

View File

@ -1,5 +1,5 @@
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
import { sep } from "path";
/**
*
* @description 便
@ -15,8 +15,8 @@ class file {
*/
protected static createPath(filePath: string): boolean {
// 获取完整目录(去除最后一位的文件字段)
let dir = filePath.substring(0, filePath.lastIndexOf("/"));
if (dir == "" || dir == null) dir = "./"; // 不写目录名 => 根目录
let dir = filePath.substring(0, filePath.lastIndexOf(sep));
if (dir == "" || dir == null) dir = `.${sep}`; // 不写目录名 => 根目录
// 文件夹不存在
if (!existsSync(dir)) {