@arktype/fs
Advanced tools
Comparing version 0.0.14 to 0.0.15
11
fs.ts
@@ -6,4 +6,4 @@ import { | ||
mkdirSync, | ||
readFileSync, | ||
readdirSync, | ||
readFileSync, | ||
rmSync, | ||
@@ -16,3 +16,3 @@ statSync, | ||
import * as process from "node:process" | ||
import { fileURLToPath, URL } from "node:url" | ||
import { URL, fileURLToPath } from "node:url" | ||
import { caller } from "./caller.js" | ||
@@ -42,3 +42,3 @@ import { shell } from "./shell.js" | ||
export const writeJson = (path: string, data: object): void => | ||
writeFileSync(path, JSON.stringify(data, null, 4) + "\n") | ||
writeFileSync(path, `${JSON.stringify(data, null, 4)}\n`) | ||
@@ -82,3 +82,4 @@ export const rmRf = (target: string): void => | ||
const nestedPaths = isDir ? walkPaths(path, options) : [] | ||
return [...paths, ...(excludeCurrent ? [] : [path]), ...nestedPaths] | ||
paths.push(...(excludeCurrent ? [] : [path]), ...nestedPaths) | ||
return paths | ||
}, []) | ||
@@ -88,3 +89,3 @@ | ||
export const filePath = (path: string): string => { | ||
let file | ||
let file: string | ||
if (path.includes("://")) { | ||
@@ -91,0 +92,0 @@ // is a url, e.g. file://, or https:// |
@@ -152,9 +152,9 @@ // Copied from unmaintained package https://github.com/bevry/get-current-line to fix imports | ||
(offset.file && | ||
(typeof offset.file === "string" | ||
? location.file.includes(offset.file) | ||
: offset.file.test(location.file))) || | ||
(typeof offset.file === "string" ? | ||
location.file.includes(offset.file) | ||
: offset.file.test(location.file))) || | ||
(offset.method && | ||
(typeof offset.method === "string" | ||
? location.method.includes(offset.method) | ||
: offset.method.test(location.method))) | ||
(typeof offset.method === "string" ? | ||
location.method.includes(offset.method) | ||
: offset.method.test(location.method))) | ||
) { | ||
@@ -161,0 +161,0 @@ // we are found, and we should exit immediatelyg, so return with the frame offset applied |
@@ -1,6 +0,6 @@ | ||
import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs"; | ||
import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs"; | ||
import { homedir } from "node:os"; | ||
import { dirname, join, parse } from "node:path"; | ||
import * as process from "node:process"; | ||
import { fileURLToPath, URL } from "node:url"; | ||
import { URL, fileURLToPath } from "node:url"; | ||
import { caller } from "./caller.js"; | ||
@@ -23,3 +23,3 @@ import { shell } from "./shell.js"; | ||
export const readJson = (path) => JSON.parse(readFileSync(path, { encoding: "utf8" })); | ||
export const writeJson = (path, data) => writeFileSync(path, JSON.stringify(data, null, 4) + "\n"); | ||
export const writeJson = (path, data) => writeFileSync(path, `${JSON.stringify(data, null, 4)}\n`); | ||
export const rmRf = (target) => rmSync(target, { recursive: true, force: true }); | ||
@@ -43,3 +43,4 @@ export const cpR = (from, to) => cpSync(from, to, { recursive: true, force: true }); | ||
const nestedPaths = isDir ? walkPaths(path, options) : []; | ||
return [...paths, ...(excludeCurrent ? [] : [path]), ...nestedPaths]; | ||
paths.push(...(excludeCurrent ? [] : [path]), ...nestedPaths); | ||
return paths; | ||
}, []); | ||
@@ -46,0 +47,0 @@ /** Fetch the file and directory paths from a path, uri, or `import.meta.url` */ |
@@ -92,8 +92,8 @@ // Copied from unmaintained package https://github.com/bevry/get-current-line to fix imports | ||
if ((offset.file && | ||
(typeof offset.file === "string" | ||
? location.file.includes(offset.file) | ||
(typeof offset.file === "string" ? | ||
location.file.includes(offset.file) | ||
: offset.file.test(location.file))) || | ||
(offset.method && | ||
(typeof offset.method === "string" | ||
? location.method.includes(offset.method) | ||
(typeof offset.method === "string" ? | ||
location.method.includes(offset.method) | ||
: offset.method.test(location.method)))) { | ||
@@ -100,0 +100,0 @@ // we are found, and we should exit immediatelyg, so return with the frame offset applied |
{ | ||
"name": "@arktype/fs", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "David Blass", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91608
27
1049