Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/file-io

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/file-io - npm Package Compare versions

Comparing version 1.2.7 to 1.3.0

8

CHANGELOG.md
# Change Log
- **Last updated**: 2024-02-10T08:59:56Z
- **Last updated**: 2024-02-19T15:50:26Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,8 @@

## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.0) (2024-02-19)
#### 🚀 Features
- add ensureDir() ([8ca3085](https://github.com/thi-ng/umbrella/commit/8ca3085))
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.2.0) (2024-01-26)

@@ -14,0 +20,0 @@

/**
* Assumes given path is to a directory. Checks if the dir exists and if not
* attempts to create it and then returns true. Otherwise returns false.
*
* @param dir
*/
export declare const ensureDir: (dir: string) => boolean;
/**
* Checks if the directory for given file `path` already exists, and if not the

@@ -13,3 +20,4 @@ * case, creates it. Returns true if the latter case.

/**
* Returns true if `path` is a directory (assumes path exists).
* Returns true if `path` is a directory (assumes path exists, if not throws an
* error).
*

@@ -16,0 +24,0 @@ * @param path

9

dir.js
import { existsSync, mkdirSync, statSync } from "fs";
import { sep } from "path";
const ensureDirForFile = (path) => {
const dir = path.substring(0, path.lastIndexOf(sep));
return dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
};
import { dirname } from "path";
const ensureDir = (dir) => dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
const ensureDirForFile = (path) => ensureDir(dirname(path));
const isDirectory = (path) => statSync(path).isDirectory();
export {
ensureDir,
ensureDirForFile,
isDirectory
};
{
"name": "@thi.ng/file-io",
"version": "1.2.7",
"version": "1.3.0",
"description": "Assorted file I/O utils (with logging support) for NodeJS",

@@ -123,3 +123,3 @@ "type": "module",

},
"gitHead": "25ee18f7db6d03f0b76787267ab071d16df94888\n"
"gitHead": "ea2ec2e4f14c572bbfac00c43953a6c4033da09e\n"
}
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