Skip to content

Commit

Permalink
Release v0.3.8 (#56)
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
  • Loading branch information
bdistin committed Dec 17, 2018
1 parent 1f9505c commit f557b6d
Show file tree
Hide file tree
Showing 10 changed files with 4,149 additions and 47 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tslint.json
.travis.yml
package-lock.json
README.md
yarn.lock
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
language: node_js
node_js:
- "8"
install: npm install
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.12.3
- export PATH=$HOME/.yarn/bin:$PATH
install: yarn
jobs:
include:
- stage: lint
script: npm run test:lint
script: yarn run test:lint
- stage: coverage
script: bash ./scripts/.travis-coverage.sh
- # Node 9 test
script: bash ./scripts/.travis-coverage.sh
node_js:
- "9"
- # Node 10 test
script: bash ./scripts/.travis-coverage.sh
node_js:
- "10"
- # Node 11 test
script: bash ./scripts/.travis-coverage.sh
node_js:
- "11"
- stage: deploy
script: bash ./scripts/.travis-deploy.sh
cache:
yarn: true
directories:
- node_modules
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fs-nextra",
"version": "0.3.7",
"version": "0.3.8",
"description": "Node.js V8 native fs enhanced with util.promisify and standard extra methods.",
"main": "src/index.js",
"types": "typings/index.d.ts",
Expand Down Expand Up @@ -36,13 +36,13 @@
},
"devDependencies": {
"@types/node": "^10.1.3",
"ava": "^0.25.0",
"ava": "^1.0.1",
"codacy-coverage": "^3.0.0",
"eslint": "^5.2.0",
"eslint-config-klasa": "github:dirigeants/klasa-lint",
"ink-docstrap": "github:bdistin/docstrap",
"jsdoc": "github:jsdoc3/jsdoc",
"nyc": "^12.0.1",
"nyc": "^13.0.1",
"tslint": "^5.7.0",
"tsubaki": "^1.2.0",
"typescript": "^3.0.1"
Expand Down
2 changes: 1 addition & 1 deletion src/nextra/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { scanDeep } = require('../util');
*/

/**
* Recursivly scans a directory, returning a map of stats keyed on the full path to the item.
* Recursively scans a directory, returning a map of stats keyed on the full path to the item.
* @function scan
* @memberof fsn/nextra
* @param {string} root The path to scan
Expand Down
64 changes: 38 additions & 26 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,39 +139,51 @@ exports.startCopy = async (mySource, options) => {
if (options.filter && !options.filter(mySource, options.targetPath)) return null;
const myStat = options.dereference ? stat : lstat;
const stats = await myStat(mySource);
let target = mySource.replace(options.currentPath, this.replaceEsc(options.targetPath));

if (stats.isDirectory()) {
const target = mySource.replace(options.currentPath, options.targetPath.replace('$', '$$$$'));
if (this.isSrcKid(mySource, target)) throw new Error('FS-NEXTRA: Copying a parent directory into a child will result in an infinite loop.');
if (await this.isWritable(target)) {
await mkdir(target, stats.mode);
await chmod(target, stats.mode);
}
const items = await readdir(mySource);
return Promise.all(items.map(item => this.startCopy(join(mySource, item), options)));
} else if (stats.isFile() || stats.isCharacterDevice() || stats.isBlockDevice()) {
let target = mySource.replace(options.currentPath, options.targetPath.replace('$', '$$$$'));
return this.copyDir(mySource, target, stats, options);
} else if (stats.isFile() || stats.isCharacterDevice() || stats.isBlockDevice() || stats.isSymbolicLink()) {
const tstats = await stat(target).catch(() => null);
if (tstats && tstats.isDirectory()) target = join(target, basename(mySource));
if (await this.isWritable(target)) return copyFile(mySource, target, options);
else if (options.overwrite) return unlink(target).then(() => copyFile(mySource, target, options));
else if (options.errorOnExist) throw new Error(`${target} already exists`);
} else if (stats.isSymbolicLink()) {
let target = mySource.replace(options.currentPath, options.targetPath);
const tstats = await stat(target).catch(() => null);
if (tstats && tstats.isDirectory()) target = join(target, basename(mySource));
let resolvedPath = await readlink(mySource);
if (options.dereference) resolvedPath = resolve(process.cwd(), resolvedPath);
if (await this.isWritable(target)) return symlink(resolvedPath, target);
let targetDest = await readlink(target);
if (options.dereference) targetDest = resolve(process.cwd(), targetDest);
if (targetDest === resolvedPath) return null;
await unlink(target);
return symlink(resolvedPath, target);

return stats.isSymbolicLink() ?
this.copyLink(mySource, target, options) :
this.copyFile(mySource, target, options);
}
throw new Error('FS-NEXTRA: An Unknown error has occurred in startCopy.');
};

exports.copyDir = async (mySource, target, stats, options) => {
if (this.isSrcKid(mySource, target)) throw new Error('FS-NEXTRA: Copying a parent directory into a child will result in an infinite loop.');
if (await this.isWritable(target)) {
await mkdir(target, stats.mode);
await chmod(target, stats.mode);
}
throw new Error('FS-NEXTRA: An Unkown error has occured in startCopy.');
const items = await readdir(mySource);
return Promise.all(items.map(item => this.startCopy(join(mySource, item), options)));
};

exports.copyFile = async (mySource, target, options) => {
if (await this.isWritable(target)) return copyFile(mySource, target, options);
else if (options.overwrite) return unlink(target).then(() => copyFile(mySource, target, options));
else if (options.errorOnExist) throw new Error(`${target} already exists`);
return null;
};

exports.copyLink = async (mySource, target, options) => {
let resolvedPath = await readlink(mySource);
if (options.dereference) resolvedPath = resolve(process.cwd(), resolvedPath);
if (await this.isWritable(target)) return symlink(resolvedPath, target);
let targetDest = await readlink(target);
if (options.dereference) targetDest = resolve(process.cwd(), targetDest);
if (targetDest === resolvedPath) return null;
await unlink(target);
return symlink(resolvedPath, target);
};

exports.replaceEsc = (str) => str.replace(/\$/g, '$$');

exports.isSrcKid = (src, dest) => {
src = resolve(src);
dest = resolve(dest);
Expand Down
4 changes: 2 additions & 2 deletions test/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ava('File to Existing File', async test => {
ava('File to Existing File w/ errorOnExist', async test => {
const newFile = tempFile();
const file = tempFile();
await test.throws(nextra.copy(file, newFile, { overwrite: false, errorOnExist: true }));
await test.throwsAsync(nextra.copy(file, newFile, { overwrite: false, errorOnExist: true }));
});

ava('File to Empty Directory', async test => {
Expand Down Expand Up @@ -77,7 +77,7 @@ ava('Symlink to Existing Symlink', async test => {
ava('Duplicated Directories', async test => {
const dir = tempDir();
tempFile(dir);
await test.throws(nextra.copy(dir, dir));
await test.throwsAsync(nextra.copy(dir, dir));
});

ava('filter shortcut', async test => {
Expand Down
8 changes: 4 additions & 4 deletions test/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ava('standard usage', async test => {
const move = tempFileLoc();
await nextra.move(existing, move, { overwrite: true });

await test.notThrows(fs.accessAsync(move));
await test.throws(fs.accessAsync(existing));
await test.notThrowsAsync(fs.accessAsync(move));
await test.throwsAsync(fs.accessAsync(existing));
});

ava('self', async test => {
Expand All @@ -23,6 +23,6 @@ ava('no overwrite', async test => {
const move = tempFileLoc();
await nextra.move(existing, move, { overwrite: false });

await test.notThrows(fs.accessAsync(move));
await test.throws(fs.accessAsync(existing));
await test.notThrowsAsync(fs.accessAsync(move));
await test.throwsAsync(fs.accessAsync(existing));
});
6 changes: 3 additions & 3 deletions test/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const nextra = require('../src');
ava('file', async test => {
const file = tempFile();
await nextra.remove(file);
await test.throws(fs.accessAsync(file));
await test.throwsAsync(fs.accessAsync(file));
});

ava('non-existant file', async test => {
Expand All @@ -15,14 +15,14 @@ ava('non-existant file', async test => {
ava('empty directory', async test => {
const dir = tempDir();
await nextra.remove(dir);
await test.throws(fs.accessAsync(dir));
await test.throwsAsync(fs.accessAsync(dir));
});

ava('full directory', async test => {
const dir = tempDir();
tempFile(dir);
await nextra.remove(dir);
await test.throws(fs.accessAsync(dir));
await test.throwsAsync(fs.accessAsync(dir));
});

ava('non-existant directory', async test => {
Expand Down
4 changes: 2 additions & 2 deletions test/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ava('file', async test => {
});

ava('non-existant file', async test => {
await test.throws(nextra.scan(tempFileLoc()));
await test.throwsAsync(nextra.scan(tempFileLoc()));
});

ava('empty directory', async test => {
Expand All @@ -26,7 +26,7 @@ ava('full directory', async test => {
});

ava('non-existant directory', async test => {
await test.throws(nextra.scan(tempDirLoc()));
await test.throwsAsync(nextra.scan(tempDirLoc()));
});

ava('deep directory', async test => {
Expand Down
Loading

0 comments on commit f557b6d

Please sign in to comment.