Socket
Socket
Sign inDemoInstall

fs-jetpack

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-jetpack - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

3

CHANGELOG.md

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

# 2.4.0 (2020-05-15)
- `write()` can accept `mode` as a parameter
# 2.3.0 (2020-05-03)

@@ -2,0 +5,0 @@ - `inspectTree()` now supports `times` option.

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

validate.options(methodSignature, "options", options, {
mode: ["string", "number"],
atomic: ["boolean"],

@@ -20,0 +21,0 @@ jsonIndent: ["number"]

2

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

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

@@ -522,2 +522,3 @@ 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)

`options` (optional) `Object` with possible fields:
* `mode` file will be created with given mode. Value could be number (eg. `0o700`) or string (eg. `'700'`).
* `atomic` (default `false`) if set to `true` the file will be written using strategy which is much more resistant to data loss. The trick is very simple, [read this to get the concept](http://stackoverflow.com/questions/17047994/transactionally-writing-files-in-node-js).

@@ -524,0 +525,0 @@ * `jsonIndent` (defaults to 2) if writing JSON data this tells how many spaces should one indentation have.

@@ -125,2 +125,44 @@ import * as fse from "fs-extra";

if (process.platform !== "win32") {
describe("sets mode of the file (unix only)", () => {
const preparations = () => {
fse.writeFileSync("file.txt", "abc", { mode: "700" });
};
const expectations = () => {
path("file.txt").shouldBeFileWithContent("xyz");
path("file.txt").shouldHaveMode("711");
};
it("sync, mode passed as string", () => {
jetpack.write("file.txt", "xyz", { mode: "711" });
expectations();
});
it("sync, mode passed as number", () => {
jetpack.write("file.txt", "xyz", { mode: 0o711 });
expectations();
});
it("async, mode passed as string", done => {
jetpack
.writeAsync("file.txt", "xyz", { mode: "711" })
.then(() => {
expectations();
done();
})
.catch(done);
});
it("async, mode passed as number", done => {
jetpack
.writeAsync("file.txt", "xyz", { mode: 0o711 })
.then(() => {
expectations();
done();
})
.catch(done);
});
});
}
describe("can create nonexistent parent directories", () => {

@@ -127,0 +169,0 @@ const expectations = () => {

@@ -85,2 +85,3 @@ /// <reference types="node" />

type WriteOptions = {
mode?: string | number;
atomic?: boolean;

@@ -87,0 +88,0 @@ jsonIndent?: number;

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