修复系统目录
This commit is contained in:
parent
d5cedac3ff
commit
257fc2a909
@ -2,6 +2,7 @@
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.file = void 0;
|
exports.file = void 0;
|
||||||
var fs_1 = require("fs");
|
var fs_1 = require("fs");
|
||||||
|
var path_1 = require("path");
|
||||||
/**
|
/**
|
||||||
* 文件操作类
|
* 文件操作类
|
||||||
* @description 更加语义化的简便文件操作。
|
* @description 更加语义化的简便文件操作。
|
||||||
@ -19,9 +20,9 @@ var file = /** @class */ (function () {
|
|||||||
*/
|
*/
|
||||||
file.createPath = function (filePath) {
|
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)
|
if (dir == "" || dir == null)
|
||||||
dir = "./"; // 不写目录名 => 根目录
|
dir = "." + path_1.sep; // 不写目录名 => 根目录
|
||||||
// 文件夹不存在
|
// 文件夹不存在
|
||||||
if (!fs_1.existsSync(dir)) {
|
if (!fs_1.existsSync(dir)) {
|
||||||
var actionNotice = fs_1.mkdirSync(dir, { recursive: true });
|
var actionNotice = fs_1.mkdirSync(dir, { recursive: true });
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
|
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
|
||||||
|
import { sep } from "path";
|
||||||
/**
|
/**
|
||||||
* 文件操作类
|
* 文件操作类
|
||||||
* @description 更加语义化的简便文件操作。
|
* @description 更加语义化的简便文件操作。
|
||||||
@ -15,8 +15,8 @@ class file {
|
|||||||
*/
|
*/
|
||||||
protected static createPath(filePath: string): boolean {
|
protected static createPath(filePath: string): boolean {
|
||||||
// 获取完整目录(去除最后一位的文件字段)
|
// 获取完整目录(去除最后一位的文件字段)
|
||||||
let dir = filePath.substring(0, filePath.lastIndexOf("/"));
|
let dir = filePath.substring(0, filePath.lastIndexOf(sep));
|
||||||
if (dir == "" || dir == null) dir = "./"; // 不写目录名 => 根目录
|
if (dir == "" || dir == null) dir = `.${sep}`; // 不写目录名 => 根目录
|
||||||
|
|
||||||
// 文件夹不存在
|
// 文件夹不存在
|
||||||
if (!existsSync(dir)) {
|
if (!existsSync(dir)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user