Socket
Socket
Sign inDemoInstall

fs-jetpack

Package Overview
Dependencies
12
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.2.0

lib/tmp_dir.js

3

CHANGELOG.md

@@ -0,1 +1,4 @@

# 3.2.0 (2020-10-15)
- Ability to create temporary directories with `tmpDir()` method
# 3.1.0 (2020-07-19)

@@ -2,0 +5,0 @@ - `move()` can move file or directory between devices (thanks @papb)

@@ -79,1 +79,11 @@ # Cool things about fs-jetpack

```
## 4. Create and clean temporary files with ease
```js
const tmp = jetpack.tmpDir();
tmp.append("data.txt", "First chunk of data");
tmp.append("data.txt", "Second chunk of data");
tmp.append("data.txt", "Third chunk of data");
tmp.copy("data.txt", "/some/other/path/data.txt");
tmp.remove();
```

@@ -20,2 +20,3 @@ "use strict";

const streams = require("./streams");
const tmpDir = require("./tmp_dir");
const write = require("./write");

@@ -225,2 +226,16 @@

tmpDir: options => {
tmpDir.validateInput("tmpDir", options);
const pathOfCreatedDirectory = tmpDir.sync(getCwdPath(), options);
return cwd(pathOfCreatedDirectory);
},
tmpDirAsync: options => {
tmpDir.validateInput("tmpDirAsync", options);
return new Promise((resolve, reject) => {
tmpDir.async(getCwdPath(), options).then(pathOfCreatedDirectory => {
resolve(cwd(pathOfCreatedDirectory));
}, reject);
});
},
write: (path, data, options) => {

@@ -227,0 +242,0 @@ write.validateInput("write", path, data, options);

2

package.json
{
"name": "fs-jetpack",
"description": "Better file system API",
"version": "3.1.0",
"version": "3.2.0",
"author": "Jakub Szwacz <jakub@szwacz.com>",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -27,8 +27,9 @@ fs-jetpack [![Build Status](https://travis-ci.org/szwacz/fs-jetpack.svg?branch=master)](https://travis-ci.org/szwacz/fs-jetpack) [![Build status](https://ci.appveyor.com/api/projects/status/er206e91fpuuqf58?svg=true)](https://ci.appveyor.com/project/szwacz/fs-jetpack) [![codecov](https://codecov.io/gh/szwacz/fs-jetpack/branch/master/graph/badge.svg)](https://codecov.io/gh/szwacz/fs-jetpack)

[list](#listpath)
[move](#movefrom-to)
[move](#movefrom-to-options)
[path](#pathparts)
[read](#readpath-returnas)
[remove](#removepath)
[rename](#renamepath-newname)
[rename](#renamepath-newname-options)
[symlink](#symlinksymlinkvalue-path)
[tmpDir](#tmpdiroptions)
[write](#writepath-data-options)

@@ -517,3 +518,30 @@

## tmpDir([options])
asynchronous: **tmpDirAsync([options])**
Creates temporary directory with random, unique name.
**arguments:**
`options` (optional) `Object` with possible fields:
* `prefix` prefix to be added to created random directory name. Defaults to none.
* `basePath` the path where temporary directory should be created. Defaults to [https://nodejs.org/api/os.html#os_os_tmpdir](os.tmpdir).
**returns:**
New CWD context with temporary directory specified in `path` as CWD (see docs of `cwd()` method for explanation).
**examples:**
```javascript
// Creates temporary directory, e.g. /tmp/90ed0f0f4a0ba3b1433c5b51ad8fc76b
jetpack.tempDir()
// Creates temporary directory with a prefix, e.g. /tmp/foo_90ed0f0f4a0ba3b1433c5b51ad8fc76b
jetpack.tempDir({ prefix: "foo_" })
// Creates temporary directory on given path, e.g. /some/other/path/90ed0f0f4a0ba3b1433c5b51ad8fc76b
jetpack.tempDir({ basePath: "/some/other/path" })
// Creates temporary directory on jetpack.cwd() path
jetpack.tempDir({ basePath: "." })
// Create temporary directory and write a file to that directory
jetpack.tempDir().write("foo.txt", "Hello world!");
```
## write(path, data, [options])

@@ -520,0 +548,0 @@ asynchronous: **writeAsync(path, data, [options])**

@@ -98,2 +98,7 @@ /// <reference types="node" />

type TmpDirOptions = {
prefix?: string;
basePath?: string;
};
// API has the same set of synchronous and asynchronous methods.

@@ -408,2 +413,16 @@ // All async methods are promise based (no callbacks).

/**
* Creates temporary directory.
*
* @param options
*/
tmpDir(options?: TmpDirOptions): FSJetpack;
/**
* Creates temporary directory.
*
* @param options
*/
tmpDirAsync(options?: TmpDirOptions): Promise<FSJetpack>;
/**
* Writes data to file. If any parent directory in `path` doesn't exist it will be created (like `mkdir -p`).

@@ -410,0 +429,0 @@ *

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc