Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
16 changed files
with
514 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { tempFile } = require('../util'); | ||
const { copyFile } = require('../fs'); | ||
|
||
const move = require('./move'); | ||
|
||
/** | ||
* @function copyFileAtomic | ||
* @memberof fsn/nextra | ||
* @param {string} source The path to the file you want to copy | ||
* @param {string} destination The path to the file destination | ||
* @param {writeOptions|string} [options] The write options or the encoding string. | ||
* @return {Promise<void>} {description} | ||
*/ | ||
module.exports = async function copyFileAtomic(source, destination, options) { | ||
const tempPath = tempFile(); | ||
await copyFile(source, tempPath, options); | ||
return move(tempPath, destination, { overwrite: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { dirname } = require('path'); | ||
|
||
const { copyFile } = require('../fs'); | ||
|
||
const copyFileAtomic = require('./copyFileAtomic'); | ||
const mkdirs = require('./mkdirs'); | ||
const pathExists = require('./pathExists'); | ||
|
||
/** | ||
* Creates an file copy, making all folders required to satisfy the given file path. | ||
* @function ensureFileCopy | ||
* @memberof fsn/nextra | ||
* @param {string} source The path to the file you want to copy | ||
* @param {string} destination The path to the file destination | ||
* @param {writeOptions|string} [options] The write options or the encoding string. | ||
* @param {boolean} [atomic = false] Whether the operation should run atomicly | ||
* @return {Promise<void>} | ||
*/ | ||
/** | ||
* Creates an file copy, making all folders required to satisfy the given file path. | ||
* @function createFileCopy | ||
* @memberof fsn/nextra | ||
* @param {string} source The path to the file you want to copy | ||
* @param {string} destination The path to the file destination | ||
* @param {writeOptions|string} [options] The write options or the encoding string. | ||
* @param {boolean} [atomic = false] Whether the operation should run atomicly | ||
* @return {Promise<void>} | ||
*/ | ||
module.exports = async function createFileCopy(source, destination, options, atomic = false) { | ||
const dir = dirname(destination); | ||
if (!await pathExists(dir)) await mkdirs(dir); | ||
return atomic ? copyFileAtomic(source, destination, options) : copyFile(source, destination, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const createFileCopy = require('./createFileCopy'); | ||
|
||
/** | ||
* Creates a file copy atomically, making all folders required to satisfy the given file path. | ||
* @function ensureFileCopyAtomic | ||
* @memberof fsn/nextra | ||
* @param {string} source The path to the file you want to copy | ||
* @param {string} destination The path to the file destination | ||
* @param {writeOptions|string} [options] The write options or the encoding string. | ||
* @return {Promise<void>} | ||
*/ | ||
/** | ||
* Creates a file copy atomically, making all folders required to satisfy the given file path. | ||
* @function createFileCopyAtomic | ||
* @memberof fsn/nextra | ||
* @param {string} source The path to the file you want to copy | ||
* @param {string} destination The path to the file destination | ||
* @param {writeOptions|string} [options] The write options or the encoding string. | ||
* @return {Promise<void>} | ||
*/ | ||
module.exports = async function createFileCopyAtomic(source, destination, options) { | ||
return createFileCopy(source, destination, options, true); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"rules": { | ||
"no-inferrable-types": [false], | ||
"no-unused-expression": true, | ||
"no-duplicate-variable": true, | ||
"no-shadowed-variable": true, | ||
"comment-format": [ | ||
true, "check-space" | ||
], | ||
"indent": [ | ||
true, "tabs" | ||
], | ||
"curly": false, | ||
"class-name": true, | ||
"semicolon": [true], | ||
"triple-equals": true, | ||
"eofline": true, | ||
"no-bitwise": false, | ||
"no-console": [false], | ||
"member-access": [true, "check-accessor", "check-constructor"], | ||
"no-consecutive-blank-lines": [true], | ||
"no-parameter-properties": true, | ||
"one-line": [ | ||
false | ||
], | ||
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"], | ||
"interface-name": [true, "always-prefix"], | ||
"no-conditional-assignment": true, | ||
"use-isnan": true, | ||
"no-trailing-whitespace": true, | ||
"quotemark": [true, "single", "avoid-escape"], | ||
"no-use-before-declare": false, | ||
"whitespace": [true, | ||
"check-branch", | ||
"check-decl", | ||
"check-operator", | ||
"check-module", | ||
"check-separator", | ||
"check-type", | ||
"check-typecast" | ||
], | ||
"typedef-whitespace": [ | ||
true, | ||
{ | ||
"call-signature": "nospace", | ||
"index-signature": "nospace", | ||
"parameter": "nospace", | ||
"property-declaration": "nospace", | ||
"variable-declaration": "nospace" | ||
}, | ||
{ | ||
"call-signature": "onespace", | ||
"index-signature": "onespace", | ||
"parameter": "onespace", | ||
"property-declaration": "onespace", | ||
"variable-declaration": "onespace" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.