Skip to content

Commit

Permalink
chore: 🤖 catch up with master
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Nov 26, 2019
2 parents 8cd782a + 7059776 commit ab1aa4d
Show file tree
Hide file tree
Showing 18 changed files with 1,174 additions and 4,292 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: streamich
2 changes: 1 addition & 1 deletion .nvmrc
@@ -1 +1 @@
8.16.0
8.16.2
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -8,7 +8,7 @@ cache:
notifications:
email: false
node_js:
- '11'
- '12'
- '10'
- '8'
script:
Expand All @@ -18,7 +18,7 @@ matrix:
allow_failures: []
fast_finish: true
after_success:
- yarn semantic-release
- npx semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
44 changes: 24 additions & 20 deletions CHANGELOG.md
@@ -1,64 +1,68 @@
## [2.15.4](https://github.com/streamich/memfs/compare/v2.15.3...v2.15.4) (2019-06-01)
## [2.17.1](https://github.com/streamich/memfs/compare/v2.17.0...v2.17.1) (2019-11-26)

### Bug Fixes

- set-up semantic-release packages ([0554c7e](https://github.com/streamich/memfs/commit/0554c7e9ae472e4a3f7afe47d5aa990abd7f05bf))

## [2.15.5](https://github.com/streamich/memfs/compare/v2.15.4...v2.15.5) (2019-07-16)

### Bug Fixes

* 🐛 accept `null` as value in `fromJSON` functions ([9e1af7d](https://github.com/streamich/memfs/commit/9e1af7d))
* 🐛 annotate return type of `toJSON` functions ([6609840](https://github.com/streamich/memfs/commit/6609840))
- check for process ([8b9b00c](https://github.com/streamich/memfs/commit/8b9b00c))
- check for process ([#396](https://github.com/streamich/memfs/issues/396)) ([2314dad](https://github.com/streamich/memfs/commit/2314dad))

## [2.15.3](https://github.com/streamich/memfs/compare/v2.15.2...v2.15.3) (2019-06-01)
## [2.15.4](https://github.com/streamich/memfs/compare/v2.15.3...v2.15.4) (2019-06-01)

### Bug Fixes

- 🐛 accept `null` as value in `fromJSON` functions ([9e1af7d](https://github.com/streamich/memfs/commit/9e1af7d))
- 🐛 annotate return type of `toJSON` functions ([6609840](https://github.com/streamich/memfs/commit/6609840))

## [2.15.3](https://github.com/streamich/memfs/compare/v2.15.2...v2.15.3) (2019-06-01)

### Bug Fixes

* 🐛 mocks process.emitWarning for browser compatibility ([e3456b2](https://github.com/streamich/memfs/commit/e3456b2)), closes [#374](https://github.com/streamich/memfs/issues/374)
- 🐛 mocks process.emitWarning for browser compatibility ([e3456b2](https://github.com/streamich/memfs/commit/e3456b2)), closes [#374](https://github.com/streamich/memfs/issues/374)

## [2.15.2](https://github.com/streamich/memfs/compare/v2.15.1...v2.15.2) (2019-02-16)


### Bug Fixes

* 🐛 BigInt type handling ([c640f25](https://github.com/streamich/memfs/commit/c640f25))
- 🐛 BigInt type handling ([c640f25](https://github.com/streamich/memfs/commit/c640f25))

## [2.15.1](https://github.com/streamich/memfs/compare/v2.15.0...v2.15.1) (2019-02-09)


### Bug Fixes

* 🐛 show directory path when throwing EISDIR in mkdir ([9dc7007](https://github.com/streamich/memfs/commit/9dc7007))
* 🐛 throw when creating root directory ([f77fa8b](https://github.com/streamich/memfs/commit/f77fa8b)), closes [#325](https://github.com/streamich/memfs/issues/325)
- 🐛 show directory path when throwing EISDIR in mkdir ([9dc7007](https://github.com/streamich/memfs/commit/9dc7007))
- 🐛 throw when creating root directory ([f77fa8b](https://github.com/streamich/memfs/commit/f77fa8b)), closes [#325](https://github.com/streamich/memfs/issues/325)

# [2.15.0](https://github.com/streamich/memfs/compare/v2.14.2...v2.15.0) (2019-01-27)


### Features

* **volume:** add env variable to suppress fs.promise api warnings ([e6b6d0a](https://github.com/streamich/memfs/commit/e6b6d0a))
- **volume:** add env variable to suppress fs.promise api warnings ([e6b6d0a](https://github.com/streamich/memfs/commit/e6b6d0a))

## [2.14.2](https://github.com/streamich/memfs/compare/v2.14.1...v2.14.2) (2018-12-11)


### Bug Fixes

* fds to start from 0x7fffffff instead of 0xffffffff ([#277](https://github.com/streamich/memfs/issues/277)) ([31e44ba](https://github.com/streamich/memfs/commit/31e44ba))
- fds to start from 0x7fffffff instead of 0xffffffff ([#277](https://github.com/streamich/memfs/issues/277)) ([31e44ba](https://github.com/streamich/memfs/commit/31e44ba))

## [2.14.1](https://github.com/streamich/memfs/compare/v2.14.0...v2.14.1) (2018-11-29)


### Bug Fixes

* don't copy legacy files into dist ([ab8ffbb](https://github.com/streamich/memfs/commit/ab8ffbb)), closes [#263](https://github.com/streamich/memfs/issues/263)
- don't copy legacy files into dist ([ab8ffbb](https://github.com/streamich/memfs/commit/ab8ffbb)), closes [#263](https://github.com/streamich/memfs/issues/263)

# [2.14.0](https://github.com/streamich/memfs/compare/v2.13.1...v2.14.0) (2018-11-12)


### Features

* add bigint option support ([00a017e](https://github.com/streamich/memfs/commit/00a017e))
- add bigint option support ([00a017e](https://github.com/streamich/memfs/commit/00a017e))

## [2.13.1](https://github.com/streamich/memfs/compare/v2.13.0...v2.13.1) (2018-11-11)


### Bug Fixes

* 🐛 don't install semantic-release, incompat with old Node ([cd2b69c](https://github.com/streamich/memfs/commit/cd2b69c))
- 🐛 don't install semantic-release, incompat with old Node ([cd2b69c](https://github.com/streamich/memfs/commit/cd2b69c))
47 changes: 21 additions & 26 deletions docs/reference.md
Expand Up @@ -6,27 +6,27 @@ This package exports `vol` and `fs` objects which both can be used for
filesystem operations but are slightly different.

```js
import {vol, fs} from 'memfs';
import { vol, fs } from 'memfs';
```

`vol` is an instance of `Volume` constructor, it is the default volume created
for your convenience. `fs` is an *fs-like* object created from `vol` using
for your convenience. `fs` is an _fs-like_ object created from `vol` using
`createFsFromVolume(vol)`, see reference below.

All contents of the `fs` object are also exported individually, so you can use
`memfs` just like you would use the `fs` module:

```js
import {readFileSync, F_OK, ReadStream} from 'memfs';
import { readFileSync, F_OK, ReadStream } from 'memfs';
```

## `Volume` Constructor

`Volume` is a constructor function for creating new volumes:

```js
import {Volume} from 'memfs';
const vol = new Volume;
import { Volume } from 'memfs';
const vol = new Volume();
```

`Volume` implements all [Node's filesystem methods](https://nodejs.org/api/fs.html):
Expand All @@ -45,8 +45,8 @@ A new volume can be create using the `Volume.fromJSON` convenience method:

```js
const vol = Volume.fromJSON({
'/app/index.js': '...',
'/app/package.json': '...',
'/app/index.js': '...',
'/app/package.json': '...',
});
```

Expand All @@ -63,10 +63,13 @@ given in a relative form.
**Note:** To remove all existing files, use `vol.reset()` method.

```js
vol.fromJSON({
vol.fromJSON(
{
'./index.js': '...',
'./package.json': '...',
}, '/app');
},
'/app',
);
```

#### `vol.mountSync(cwd, json)`
Expand All @@ -92,7 +95,7 @@ an array of paths. A path can be a string, `Buffer` or an `URL` object.
Removes all files from the volume.

```js
vol.fromJSON({'/index.js': '...'});
vol.fromJSON({ '/index.js': '...' });
vol.toJSON(); // {'/index.js': '...' }
vol.reset();
vol.toJSON(); // {}
Expand Down Expand Up @@ -120,30 +123,22 @@ A synchronous version of `vol.mkdirp()`. This method throws.

## `createFsFromVolume(vol)`

Returns an *fs-like* object created from a `Volume` instance `vol`.
Returns an _fs-like_ object created from a `Volume` instance `vol`.

```js
import {createFsFromVolume, Volume} from 'memfs';
import { createFsFromVolume, Volume } from 'memfs';

const vol = new Volume;
const vol = new Volume();
const fs = createFsFromVolume(vol);
```

The idea behind the *fs-like* object is to make it identical to the one
The idea behind the _fs-like_ object is to make it identical to the one
you get from `require('fs')`. Here are some things this function does:

- Binds all methods, so you can do:

```js
const {createFileSync, readFileSync} = fs;
```

- Adds constants `fs.constants`, `fs.F_OK`, etc.

## Experimental fs.promise api warnings

Supress warnings when using the promise api of fs by setting
- Binds all methods, so you can do:

```js
process.env.MEMFS_DONT_WARN = true;
const { createFileSync, readFileSync } = fs;
```

- Adds constants `fs.constants`, `fs.F_OK`, etc.
27 changes: 13 additions & 14 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "memfs",
"version": "2.15.4",
"version": "2.17.1",
"description": "In-memory file-system with Node's fs API.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -14,7 +14,6 @@
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"watch": "watch \"npm run build\" ./src",
"semantic-release": "semantic-release",
"prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,js}\"",
"prettier:diff": "prettier -l \"src/**/*.{ts,js}\"",
"tslint": "tslint \"src/**/*.ts\" -t verbose",
Expand All @@ -30,23 +29,23 @@
"fs-monkey": "^0.3.3"
},
"devDependencies": {
"@semantic-release/changelog": "3.0.4",
"@semantic-release/git": "7.0.16",
"@semantic-release/npm": "5.1.13",
"@types/jest": "23.3.14",
"@types/node": "10.14.12",
"@types/node": "10.17.6",
"cpy-cli": "2.0.0",
"husky": "1.3.1",
"jest": "24.8.0",
"prettier": "1.18.2",
"jest": "24.9.0",
"prettier": "1.19.1",
"pretty-quick": "1.11.1",
"rimraf": "2.6.3",
"semantic-release": "15.13.18",
"ts-jest": "24.0.2",
"ts-node": "8.3.0",
"tslint": "5.18.0",
"rimraf": "2.7.1",
"ts-jest": "24.1.0",
"ts-node": "8.5.2",
"tslint": "5.20.1",
"tslint-config-common": "1.6.0",
"typescript": "3.4.5"
"typescript": "3.6.4",
"semantic-release": "15.13.31",
"@semantic-release/changelog": "3.0.6",
"@semantic-release/git": "7.0.18",
"@semantic-release/npm": "5.3.4"
},
"config": {
"commitizen": {
Expand Down
14 changes: 0 additions & 14 deletions src/__tests__/process.test.ts
Expand Up @@ -19,20 +19,6 @@ describe('process', () => {
});
it('.env', () => {
expect(typeof proc.env).toBe('object');
expect(!!proc.env.MEMFS_DONT_WARN).toBe(false);
});
});
describe('using MEMFS_DONT_WARN', () => {
it('should be assignable to the process.env, and returned by createProcess', () => {
process.env.MEMFS_DONT_WARN = 'true';
const proc = createProcess();
expect(!!proc.env.MEMFS_DONT_WARN).toBe(true);
delete process.env.MEMFS_DONT_WARN;
});
it('should by default show warnings (in volume.ts)', () => {
const proc = createProcess();
const promisesWarn = !proc.env.MEMFS_DONT_WARN;
expect(promisesWarn).toBe(true);
});
});
});
12 changes: 12 additions & 0 deletions src/__tests__/volume.test.ts
Expand Up @@ -131,6 +131,18 @@ describe('volume', () => {
});
});

it('Specify a file export path', () => {
const vol = Volume.fromJSON({
'/foo': 'bar',
'/dir/a': 'b',
'/dir2/a': 'b',
'/dir2/c': 'd',
});
expect(vol.toJSON(['/dir/a'])).toEqual({
'/dir/a': 'b',
});
});

it('Accumulate exports on supplied object', () => {
const vol = Volume.fromJSON({
'/foo': 'bar',
Expand Down
14 changes: 14 additions & 0 deletions src/__tests__/volume/realpathSync.test.ts
@@ -0,0 +1,14 @@
import { create } from '../util';

describe('.realpath(...)', () => {
it('works with symlinks, #463', () => {
const vol = create({});
vol.mkdirSync('/a');
vol.mkdirSync('/c');
vol.writeFileSync('/c/index.js', 'alert(123);');
vol.symlinkSync('/c', '/a/b');

const path = vol.realpathSync('/a/b/index.js');
expect(path).toBe('/c/index.js');
});
});
14 changes: 14 additions & 0 deletions src/__tests__/volume/statSync.test.ts
@@ -0,0 +1,14 @@
import { create } from '../util';

describe('.statSync(...)', () => {
it('works with symlinks, #463', () => {
const vol = create({});
vol.mkdirSync('/a');
vol.mkdirSync('/c');
vol.writeFileSync('/c/index.js', 'alert(123);');
vol.symlinkSync('/c', '/a/b');

const stats = vol.statSync('/a/b/index.js');
expect(stats.size).toBe(11);
});
});
13 changes: 13 additions & 0 deletions src/__tests__/volume/toString.test.ts
@@ -0,0 +1,13 @@
import { create } from '../util';

describe('toString', () => {
it('allow files to be named "toString", #463', () => {
const vol = create({});
vol.writeFileSync('/toString', 'pwned');

expect(vol.readFileSync('/toString', 'utf8')).toBe('pwned');
expect(vol.toJSON()).toEqual({
'/toString': 'pwned',
});
});
});
1 change: 1 addition & 0 deletions src/encoding.ts
@@ -1,3 +1,4 @@
import { Buffer } from './internal/buffer';
import * as errors from './internal/errors';

export type TDataOut = string | Buffer; // Data formats we give back to users.
Expand Down
10 changes: 10 additions & 0 deletions src/internal/buffer.ts
@@ -0,0 +1,10 @@
import { Buffer } from 'buffer';

function bufferV0P12Ponyfill(arg0: any, ...args: any): Buffer {
return new Buffer(arg0, ...args);
}

const bufferAllocUnsafe = Buffer.allocUnsafe || bufferV0P12Ponyfill;
const bufferFrom = Buffer.from || bufferV0P12Ponyfill;

export { Buffer, bufferAllocUnsafe, bufferFrom };

0 comments on commit ab1aa4d

Please sign in to comment.