Skip to content

Commit

Permalink
Release v0.4.1 (#86)
Browse files Browse the repository at this point in the history
* remove hard-coded functions names for `promisify` (#9)

* remove hard-coded functions names for `promisify`

* fixing eslint

* fix code style

* add atomics keyword, and bump to v0.1.5

* It requires Node.js 8.1.0 (#10)

* fix npm

npm wouldn't let me fix the pulished version correctly, had to bump package to fix.

* Modualized Refactor and Docs (#12)

* modualise and document

* fix util requires

* fix outputjsonatomic requires

* finish out docs

* generated docs

* Fix travis

* bump version to v0.2.0

* Fix lint

* remove search

the search didn't really work

* cname for js.org

* more docs customization

* More document coverage

* Fix lint

* finish documentation coverage

* Add a Codacy badge to README.md (#13)

* Add Codacy badge

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* update docs

* Create LICENSE

* update dev deps, add tests to travis, unskip all tests

* Some fixes, and a bunch more tests

I am aware builds are going to fail for a while

* Fix one test

* finish tests draft

* fix a couple tests

* fix more tests

* Fix build with test skips

* 3 more skips

* more test work

* remove fixes

* this is probably going to fail build

* maybe fixed 1 test?

* fix move test

* fix some test bugs

* skip symlink tests until I can rewrite to remove fs-mock

* Create .travis-deploy.sh

* Update package.json

* Update .travis.yml

* Update .travis-deploy.sh

* try auto docs

* Update .travis-deploy.sh

* fix .travis-deploy?

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Site build: c4a1ec1

* fix docs, from auto docs test

* Site build: b8d9a56

* Update .travis-deploy.sh

* Update .travis-deploy.sh

* Update .travis.yml

* Update .travis-deploy.sh

* add .travis-deploy.sh to npmignore

* update deps

* Docs build: c947062

* Docs build: 01c52e8

* Add Greenkeeper badge 🌴 (#15)

* docs(readme): add Greenkeeper badge

* Update README.md

* Fix travis deploy

* Docs build: 21de27f

* update eslint

* Update README.md

* Docs build: 39e4515

* code cleanup

* Fix typo (#16)

* Docs build: e1f8556

* fix util mkDir

* Docs build: 011f8b7

* Fix copy error

* 0.2.1

* Copy file (#18)

* copyFile changes

* some docs, still very wip

* Update .travis.yml

* mock fs can't handle the new fs.copyFile yet

* emptyDir bugfix

* last bug fix

* Typings. (#19)

* Create tslint.json

* Fixed typos, added typings.

* Fixed all JSDocs

* minor fixes

* fix lint and friends

* missed docs

* le typings

* Docs build: 29fb5da

* update readme

* Docs build: 83dc519

* Coverage (#21)

* start coverage and docs changes

* remove docs from future master

* oops travis

* make codacy happy more tests, still wip

* progress, but mock-fs sucks

* fix scripts

* begin module structure and ditching mock-fs

* add another test to see if somethings wrong...

* oops

* Update Messages, Add test

* tests progress

* push progress

* push progress

* oops

* push progress

* oops

* finish basic tests

* small fixes

* oops

* bug fix

* test fixes

* should fix a lot of symlink bugs?

* maybe fix move tests?

* take 2 move tests

* take 3 move

* fix remove tests

* ahah!

* see how this fares for copy

* idek anymore

* try this on for size

* duh

* fingers crossed

* more copy coverage

* copy coverage

* Update README.md

* More unit tests (#22)

* copy tests

* oh yeah

* symlink copy test

* interesting edge test

* oops

* up threshold

* update npm ignore for prepping patch release

* 0.3.1

* Remove mock-fs since it's not used anymore

* Scan (#24)

* impliment scan idea (klaw without nastiness)

* impliment limit

* umm?

* ohh!

* should do the first directory.

* add filter

* fix limit

* docs

* copy paste OP

* tests

* fix test

* unneeded `async`

* typings I think

* 0.3.2

* Fixed some types (#27)

* Fixed some types

* I guess this is the fix

* chore(package): update ava to version 0.23.0 (#26)

* Add matrix testing support

* Add node 9 testing to coverage

* uh, you skipped 8...

* try again travis

* ?? travis you there?

* update lint

* chore(package): update ava to version 0.25.0 (#28)

* chore(package): update ava to version 0.25.0 (#29)

Closes #28

* fix broken test?

* Fixed typings (#30)

* Fixed typings (hopefully)

Fixed return types for createReadStream and createWriteStream
Imported Buffer to fix a ton of errors

* Fixed a missing property by just importing from fs

I don't remember what I was trying to use, but something was missing
from ReadStream/WriteStream. I just imported it from fs, to ensure
consistency.

* add fs/promises support if your node version is high enough

* bump version and add note to readme

* add node 10 tests to travis

* fix broken test?

* try again?

* bump package.json

* fix some docs

* chore(package): update codacy-coverage to version 3.0.0 (#34)

* more bugged docs

* Update @types/node to the latest version 🚀 (#36)

* chore(package): update @types/node to version 10.0.3

* Update README.md

* fix lint warnings and fix fs.promises use for node ^10.1.0

drop support for node 10.0.0 fs.promises (will fall back to regular util.promisify so not breaking)

* chore(package): update @types/node to version 10.1.3 (#39)

* chore(package): update nyc to version 12.0.1 (#41)

* Update README.md

* Update typescript requirement to ^3.0.1 (#45)

Updates the requirements on [typescript](https://github.com/Microsoft/TypeScript) to permit the latest version.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits/v3.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update eslint requirement to ^5.2.0 (#46)

Updates the requirements on [eslint](https://github.com/eslint/eslint) to permit the latest version.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/commits/v5.2.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* docs: Improved typings and docs (#43)

* doc: Updated all docs, made typings way better

* fix: fsn#emptyDir (readdir returns string[], mkdirs returns string)

* tslint: Replaced quotes

* eslint: Remove @returns tag for emptyDir

* tslint: Fix typings for fs#write

* return 'file' if lstat errors

* test: Add test for bug kyra found

* bump version for release

* fix alias `writeJsonAtomic` (#49)

* bump version for release

* Update nyc requirement from ^12.0.1 to ^13.0.1 (#51)

Updates the requirements on [nyc](https://github.com/istanbuljs/nyc) to permit the latest version.
- [Release notes](https://github.com/istanbuljs/nyc/releases)
- [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/istanbuljs/nyc/commits/v13.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update scan.js

* Chore(deps-dev): update ava requirement from ^0.25.0 to ^1.0.1 (#53)

* Chore(deps-dev): update ava requirement from ^0.25.0 to ^1.0.1

Updates the requirements on [ava](https://github.com/avajs/ava) to permit the latest version.
- [Release notes](https://github.com/avajs/ava/releases)
- [Commits](https://github.com/avajs/ava/commits/v1.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update copy.js

* Update scan.js

* Update remove.js

* Update move.js

* use yarn.lock for dependabot, add node 11 tests (#54)

* use yarn.lock for dependabot, add node 11 tests

* actually, no need to test node 9 any longer

* refactor copy to be less complex (#55)

* bump patch for new release

* switch from codacy to coveralls

* better test coverage

* typos

* add another test case

* another test

having trouble hitting the lines I want to...

* more tests

* fix expected assertions

* more tests

* lint

* badge updates

* attempt ignoring all windows specific code

* wrong path ignored

* updated comments

* see if this makes a branch difference

* more clear logic/ comments

* lint

* util coverage comments

* remove duplicate coercion

* refactor then/catch tree into try/catch await

* lint

* docs spelling

* more tests and docs fixes

* maybe fix coverage ignore?

* add appveyor config (#57)

* add appveyor config

* new line endof file

* get linux errors

* breaking: rewrite move

* test fails on both linux/windows, presumed flawed test

* add proper ignores back to the new move

* remove other clobber options

* refactor util

this might reduce coverage

* better isSrcKid

* fix bad refactor

* another copy test

* and another

* another obscure test

* bit of rewrite

* better coverage

* does this change how coverage sees branches?

* ?

* more rewrite

no .then/.catch

* symlink test

* does this get that last symlink branch?

* whoops

* one last obscure test

and hope we don't lock up travis

* fix duplicate title

* correction

dev/null is a character device, not block device :(

* Bump tslint from 5.11.0 to 5.12.0

Bumps [tslint](https://github.com/palantir/tslint) from 5.11.0 to 5.12.0.
- [Release notes](https://github.com/palantir/tslint/releases)
- [Changelog](https://github.com/palantir/tslint/blob/master/CHANGELOG.md)
- [Commits](palantir/tslint@5.11.0...5.12.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump @types/node from 10.12.15 to 10.12.17

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.15 to 10.12.17.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* coverage

* or actually

* fix superfluous argument

* clobber removed

* make prs report coverage too (#60)

* Bump @types/node from 10.12.17 to 10.12.18

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.17 to 10.12.18.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump eslint from 5.10.0 to 5.11.0

Bumps [eslint](https://github.com/eslint/eslint) from 5.10.0 to 5.11.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v5.10.0...v5.11.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump eslint from 5.11.0 to 5.11.1

Bumps [eslint](https://github.com/eslint/eslint) from 5.11.0 to 5.11.1.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v5.11.0...v5.11.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* consistent errors

* ensure strict returns and consistency sweep

* fix return type

* fix coverage

* more simplification

* whoops

* remove useless return

* revert change to mkdirs

since that slows recursive calls unnecessarily

* more cleanup and engine bump for object spread

* forgot to hit save

* Bump eslint from 5.11.1 to 5.12.0

Bumps [eslint](https://github.com/eslint/eslint) from 5.11.1 to 5.12.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v5.11.1...v5.12.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump tslint from 5.12.0 to 5.12.1

Bumps [tslint](https://github.com/palantir/tslint) from 5.12.0 to 5.12.1.
- [Release notes](https://github.com/palantir/tslint/releases)
- [Changelog](https://github.com/palantir/tslint/blob/master/CHANGELOG.md)
- [Commits](palantir/tslint@5.12.0...5.12.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump ava from 1.0.1 to 1.1.0

Bumps [ava](https://github.com/avajs/ava) from 1.0.1 to 1.1.0.
- [Release notes](https://github.com/avajs/ava/releases)
- [Commits](avajs/ava@v1.0.1...v1.1.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump typescript from 3.2.2 to 3.2.4

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.2.2 to 3.2.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.2.2...v3.2.4)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump eslint from 5.12.0 to 5.12.1

Bumps [eslint](https://github.com/eslint/eslint) from 5.12.0 to 5.12.1.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v5.12.0...v5.12.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump ava from 1.1.0 to 1.2.0

Bumps [ava](https://github.com/avajs/ava) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/avajs/ava/releases)
- [Commits](avajs/ava@v1.1.0...v1.2.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump @types/node from 10.12.18 to 10.12.19

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.18 to 10.12.19.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump @types/node from 10.12.19 to 10.12.20

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.19 to 10.12.20.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump typescript from 3.2.4 to 3.3.1

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.2.4 to 3.3.1.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.2.4...v3.3.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump @types/node from 10.12.20 to 10.12.21

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.20 to 10.12.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump eslint from 5.12.1 to 5.13.0

Bumps [eslint](https://github.com/eslint/eslint) from 5.12.1 to 5.13.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v5.12.1...v5.13.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump jsdoc from `b214273` to `10c004f`

Bumps [jsdoc](https://github.com/jsdoc3/jsdoc) from `b214273` to `10c004f`.
- [Release notes](https://github.com/jsdoc3/jsdoc/releases)
- [Commits](jsdoc/jsdoc@b214273...10c004f)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump nyc from 13.1.0 to 13.2.0

Bumps [nyc](https://github.com/istanbuljs/nyc) from 13.1.0 to 13.2.0.
- [Release notes](https://github.com/istanbuljs/nyc/releases)
- [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md)
- [Commits](istanbuljs/nyc@v13.1.0...v13.2.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump ava from 1.2.0 to 1.2.1

Bumps [ava](https://github.com/avajs/ava) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/avajs/ava/releases)
- [Commits](avajs/ava@v1.2.0...v1.2.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump @types/node from 10.12.21 to 10.12.23

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped) from 10.12.21 to 10.12.23.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump typescript from 3.3.1 to 3.3.3

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.3.1 to 3.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* TypeScript Re-Write (#83)

* wip ts rewrite

* odd?

* ah

* make min node 10

* fix appveyor

* cleaner export

* Revert "cleaner export"

This reverts commit 398a928.

* remove typings, update readme

* full sounds wrong with ts

* more official

* update npm ignore

* see if this fixes coverage

* fix coverage

* add a chmod test

* mode includes more than just the chmod

* who knows, tbh

* make it more interesting

* fk it

* switch to a basic typedocs

* fix output

* update npm description

* bump minor for new release

* run tests in typescript (#85)

* run tests in typescript

* oops, fix test

* fix linting

* real fixes

* use more yarn

* fix lint

* try this

* revert coverage reporting

* ok whatever

* might aswell change these too

* ugh, fix this

* I cba anymore

* bump patch for new release
  • Loading branch information
bdistin committed Feb 10, 2019
1 parent d62481f commit 751af8b
Show file tree
Hide file tree
Showing 38 changed files with 258 additions and 194 deletions.
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "fs-nextra",
"version": "0.4.0",
"version": "0.4.1",
"description": "Node.js native fs promises with next-generation extra methods.",
"main": "dist/index.js",
"scripts": {
"build": "npx tsc",
"test": "npm run build && npx ava test/*.js",
"test:lint": "npx eslint test && npx tslint 'src/*.ts'",
"test:coverage": "npm run coverage && npx nyc check-coverage --lines 60 --functions 60 --branches 60",
"build": "tsc",
"test": "yarn build && ava test/*.ts",
"test:lint": "tslint '{test,src}/**/*.ts'",
"test:coverage": "yarn coverage && nyc check-coverage --lines 60 --functions 60 --branches 60",
"coverage": "npx nyc npm test",
"coveralls": "npx nyc report --reporter=text-lcov | npx coveralls",
"docs": "npx typedoc --mode file --out ./docs/ ./src/",
"lint": "npx eslint --fix test && npx tslint --fix 'src/*.ts'"
"docs": "typedoc --mode file --out ./docs/ ./src/",
"lint": "tslint --fix '{test,src}/**/*.ts'"
},
"keywords": [
"atomics",
Expand Down Expand Up @@ -42,11 +42,21 @@
"eslint-config-klasa": "github:dirigeants/klasa-lint",
"nyc": "^13.0.1",
"tslint": "^5.7.0",
"ts-node": "8.0.2",
"typedoc": "^0.14.2",
"typescript": "^3.0.1"
},
"repository": {
"type": "git",
"url": "https://github.com/bdistin/fs-nextra"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}
}
6 changes: 3 additions & 3 deletions scripts/.travis-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ set -e
# For Node != 8, do nothing
if [ "$TRAVIS_NODE_VERSION" != "10" ]; then
echo -e "Build triggered with Node v${TRAVIS_NODE_VERSION} - testing without reporting."
npm run test:coverage
yarn run test:coverage
exit 0
fi

echo -e "Build triggered with Node v${TRAVIS_NODE_VERSION} - testing and reporting coverage."

npm run test:coverage
yarn run test:coverage

npm run coveralls
yarn run coveralls
4 changes: 2 additions & 2 deletions scripts/.travis-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e

if [ "$TRAVIS_BRANCH" != "master" -o -n "$TRAVIS_TAG" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Not building for a non master branch push - building without deploying."
npm run docs
yarn run docs
exit 0
fi

Expand All @@ -17,7 +17,7 @@ SHA=$(git rev-parse --verify HEAD)
TARGET_BRANCH="gh-pages"
git clone $REPO dist -b $TARGET_BRANCH

npm run docs
yarn run docs

rsync -vau docs/ dist/

Expand Down
4 changes: 2 additions & 2 deletions src/nextra/createSymlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ interface SymLinkPaths {
* @param type The type of symlink you are creating
* @param atomic Whether the operation should run atomically
*/
export default async function createSymlink(source: string, destination: string, type?: SymLinkType, atomic: boolean = false): Promise<void> {
export default async function createSymlink(source: string, destination: string, type?: SymLinkType | boolean, atomic: boolean = false): Promise<void> {
if (await pathExists(destination)) return;
if (typeof type === 'boolean') [atomic, type] = [type, undefined];

await mkdirs(dirname(destination));
const relativePath = await symlinkPaths(source, destination);

const symlinkMethod = atomic ? symlinkAtomic : symlink;
await symlinkMethod(relativePath.toDst, destination, type || await symlinkType(relativePath.toCwd));
await symlinkMethod(relativePath.toDst, destination, type as SymLinkType || await symlinkType(relativePath.toCwd));
}

const symlinkPaths = async (srcpath: string, dstPath: string): Promise<SymLinkPaths> => {
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/mkdirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default async function mkdirs(path: string, options?: MkdirsOptions | num
if (myStat.isDirectory()) return;
throw err;
}
};
}

const resolveOptions = (options: MkdirsOptions | number = {}): MkdirsOptions => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/outputFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import mkdirs from './mkdirs';
* @param options The write options or the encoding string.
* @param atomic {description}
*/
export default async function outputFile(file: string, data: string | Buffer | Uint8Array, options?: WriteOptions | string, atomic: boolean = false): Promise<void> {
export default async function outputFile(file: string, data: string | Buffer | Uint8Array, options?: WriteOptions | string | boolean, atomic: boolean = false): Promise<void> {
if (typeof options === 'boolean') [atomic, options] = [options, {}];

await mkdirs(dirname(file));
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/outputJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import mkdirs from './mkdirs';
* @param options The write options or the encoding string.
* @param atomic If the operation should be done atomically
*/
export default async function outputJSON(file: string, data: any, options?: JsonOptions, atomic: boolean = false): Promise<void> {
export default async function outputJSON(file: string, data: any, options?: JsonOptions | boolean, atomic: boolean = false): Promise<void> {
if (typeof options === 'boolean') [atomic, options] = [options, {}];

await mkdirs(dirname(file));
Expand Down
1 change: 0 additions & 1 deletion src/nextra/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface RemoveOptions {
* @param options The remove options
*/
export default async function remove(path: string, options: RemoveOptions = {}): Promise<void> {
if (typeof path !== 'string') throw new Error('FS-NEXTRA: Path should be a string');
options.maxBusyTries = typeof options.maxBusyTries === 'undefined' ? 3 : options.maxBusyTries;

for (let buysTries = 0; buysTries < options.maxBusyTries; buysTries++) {
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/writeJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface JsonOptions {
* @param {boolean} [atomic = false] Whether the operation should run atomically
* @returns {Promise<void>}
*/
export default async function writeJSON(file: string, object: any, options: JsonOptions = {}, atomic: boolean = false) {
export default async function writeJSON(file: string, object: any, options: JsonOptions | boolean = {}, atomic: boolean = false) {
if (typeof options === 'boolean') [atomic, options] = [options, {}];

const writeMethod = atomic ? writeFileAtomic : writeFile;
Expand Down
10 changes: 5 additions & 5 deletions test/copy.js → test/copy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const ava = require('ava');
const { join, basename } = require('path');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDir, tempDirLoc, tempSymlink } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { join, basename } from 'path';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDir, tempDirLoc, tempSymlink } from './lib';
import * as nextra from '../dist';

// #region Success

Expand Down
8 changes: 4 additions & 4 deletions test/copyFileAtomic.js → test/copyFileAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc } from './lib';
import * as nextra from '../dist';

ava('Standard Usage', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createFile.js → test/createFile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createFileAtomic.js → test/createFileAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createFileCopy.js → test/createFileCopy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempDir, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempDir, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createFileCopyAtomic.js → test/createFileCopyAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createLink.js → test/createLink.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/createLinkAtomic.js → test/createLinkAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
12 changes: 6 additions & 6 deletions test/createSymlink.js → test/createSymlink.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const ava = require('ava');
const { relative } = require('path');
const { promises: fs } = require('fs');
const { tempFile, tempDir, tempSymlink, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { relative } from 'path';
import { promises as fs } from 'fs';
import { tempFile, tempDir, tempSymlink, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down Expand Up @@ -55,7 +55,7 @@ ava('New File w/ Non-Existent Directories', async test => {
ava('Relative Source', async test => {
test.plan(2);

const file = './test/createSymlink.js';
const file = './test/createSymlink.ts';
const newFile = tempFileLoc();
const retVal = await nextra.createSymlink(file, newFile);
const stats = await fs.lstat(newFile);
Expand Down
8 changes: 4 additions & 4 deletions test/createSymlinkAtomic.js → test/createSymlinkAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempSymlink, tempFileLoc, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempSymlink, tempFileLoc, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('New File (Standard Usage)', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/emptyDir.js → test/emptyDir.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempDir, tempDirLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempDir, tempDirLoc } from './lib';
import * as nextra from '../dist';

ava('Non-Existent', async test => {
test.plan(2);
Expand Down
33 changes: 0 additions & 33 deletions test/lib/index.js

This file was deleted.

33 changes: 33 additions & 0 deletions test/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { tmpdir } from 'os';
import { randomBytes } from 'crypto';
import { join } from 'path';
import * as fs from 'fs';

export const uuid = (): string => {
const id = randomBytes(32).toString('hex');
return (Array(32).join('0') + id).slice(-32).replace(/^.{8}|.{4}(?!$)/g, '$&-');
};

export const dir = tmpdir();

export const tempFile = (directory?: string): string => {
const path = tempFileLoc(directory);
fs.writeFileSync(path, '');
return path;
};

export const tempDir = (directory?: string): string => {
const path = tempDirLoc(directory);
fs.mkdirSync(path);
return path;
};

export const tempSymlink = (directory?: string): string => {
const path = tempFileLoc(directory);
fs.symlinkSync(tempFile(), path);
return path;
};

export const tempFileLoc = (directory: string = dir): string => join(directory, `${uuid()}.txt`);

export const tempDirLoc = (directory: string = dir): string => join(directory, uuid());
8 changes: 4 additions & 4 deletions test/linkAtomic.js → test/linkAtomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFile, tempFileLoc } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFile, tempFileLoc } from './lib';
import * as nextra from '../dist';

ava('Standard Usage', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/mkdirs.js → test/mkdirs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempDirLoc, tempDir, tempFile } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempDirLoc, tempDir, tempFile } from './lib';
import * as nextra from '../dist';

ava('Pre-Existing Directory', async test => {
test.plan(2);
Expand Down
8 changes: 4 additions & 4 deletions test/move.js → test/move.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const ava = require('ava');
const { promises: fs } = require('fs');
const { tempFileLoc, tempDirLoc, tempFile, tempDir } = require('./lib');
const nextra = require('../dist');
import ava from 'ava';
import { promises as fs } from 'fs';
import { tempFileLoc, tempDirLoc, tempFile, tempDir } from './lib';
import * as nextra from '../dist';

// #region Success

Expand Down

0 comments on commit 751af8b

Please sign in to comment.