generated from acttoreact/ts-node-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26158bb
commit d783f88
Showing
31 changed files
with
9,962 additions
and
2,599 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules | ||
next-env.d.ts | ||
jest.config.js | ||
dist/ | ||
bin/ |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ yarn-debug.log* | |
yarn-error.log* | ||
|
||
# Compiled version | ||
dist/ | ||
bin | ||
|
||
# Runtime data | ||
pids | ||
|
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
branches: | ||
except: | ||
- /^release/ | ||
language: node_js | ||
node_js: | ||
- "12" | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"lcov", | ||
"plusplus", | ||
"respawn", | ||
"snyk", | ||
"sourcemap", | ||
"tslib" | ||
] | ||
|
This file was deleted.
Oops, something went wrong.
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,258 @@ | ||
|
||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
|
||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title> bin/tools/fs.js</title> | ||
|
||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script> | ||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<script src="./build/entry.js"></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet"> | ||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous"> | ||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/app.min.css"> | ||
<link type="text/css" rel="stylesheet" href="styles/iframe.css"> | ||
<link type="text/css" rel="stylesheet" href=""> | ||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
|
||
|
||
</head> | ||
|
||
|
||
|
||
<body class="layout small-header"> | ||
<div id="stickyNavbarOverlay"></div> | ||
|
||
|
||
<div class="top-nav"> | ||
<div class="inner"> | ||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false"> | ||
<span aria-hidden="true"></span> | ||
<span aria-hidden="true"></span> | ||
<span aria-hidden="true"></span> | ||
</a> | ||
<div class="logo"> | ||
|
||
|
||
</div> | ||
<div class="menu"> | ||
|
||
<div class="navigation"> | ||
<a | ||
href="index.html" | ||
class="link" | ||
> | ||
API Documentation | ||
</a> | ||
<div class="dropdown is-hoverable is-right"> | ||
<a class="dropdown-trigger link"> | ||
Tutorials | ||
<i class="fas fa-chevron-down fa-xs"></i> | ||
</a> | ||
<div class="dropdown-menu"> | ||
<div class="dropdown-content"> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="main"> | ||
<div | ||
class="sidebar " | ||
id="sidebarNav" | ||
> | ||
|
||
<nav> | ||
|
||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Global</h3><ul><li><a href="global.html#copyContents">copyContents</a></li><li><a href="global.html#copyFile">copyFile</a></li><li><a href="global.html#emptyFolder">emptyFolder</a></li><li><a href="global.html#ensureDir">ensureDir</a></li><li><a href="global.html#exists">exists</a></li><li><a href="global.html#getFilesRecursively">getFilesRecursively</a></li><li><a href="global.html#mkDir">mkDir</a></li><li><a href="global.html#readDir">readDir</a></li><li><a href="global.html#readFile">readFile</a></li><li><a href="global.html#rimraf">rimraf</a></li><li><a href="global.html#rmDir">rmDir</a></li><li><a href="global.html#unlink">unlink</a></li><li><a href="global.html#writeFile">writeFile</a></li></ul></div> | ||
|
||
</nav> | ||
</div> | ||
<div class="core" id="main-content-wrapper"> | ||
<div class="content"> | ||
<header class="page-title"> | ||
<p>Source</p> | ||
<h1>bin/tools/fs.js</h1> | ||
</header> | ||
|
||
|
||
|
||
|
||
|
||
<section> | ||
<article> | ||
<pre class="prettyprint source linenums"><code>"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.copyContents = exports.getFilesRecursively = exports.ensureDir = exports.emptyFolder = exports.exists = exports.unlink = exports.copyFile = exports.readFile = exports.readDir = exports.writeFile = exports.rimraf = exports.rmDir = exports.mkDir = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
const util_1 = __importDefault(require("util")); | ||
const path_1 = __importDefault(require("path")); | ||
const rimraf_1 = __importDefault(require("rimraf")); | ||
/** | ||
* Create a directory | ||
*/ | ||
exports.mkDir = util_1.default.promisify(fs_1.default.mkdir); | ||
/** | ||
* Delete a directory. | ||
*/ | ||
exports.rmDir = util_1.default.promisify(fs_1.default.rmdir); | ||
/** | ||
* The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node | ||
*/ | ||
exports.rimraf = util_1.default.promisify(rimraf_1.default); | ||
/** | ||
* Writes data to a file, replacing the file if it already exists. | ||
*/ | ||
exports.writeFile = util_1.default.promisify(fs_1.default.writeFile); | ||
/** | ||
* Read a directory. | ||
*/ | ||
exports.readDir = util_1.default.promisify(fs_1.default.readdir); | ||
/** | ||
* Reads the entire contents of a file. | ||
*/ | ||
exports.readFile = util_1.default.promisify(fs_1.default.readFile); | ||
/** | ||
* Copies `src` to `dest`. By default, dest is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination. | ||
*/ | ||
exports.copyFile = util_1.default.promisify(fs_1.default.copyFile); | ||
/** | ||
* Deletes a name and possibly the file it refers to. | ||
*/ | ||
exports.unlink = util_1.default.promisify(fs_1.default.unlink); | ||
/** | ||
* Test whether or not the given path exists by checking with the file system. | ||
* @param {fs.PathLike} pathToCheck A path to a file or directory. If a URL is provided, it must use the `file:` protocol. URL support is experimental. | ||
*/ | ||
exports.exists = (pathToCheck) => new Promise((resolve) => { | ||
fs_1.default.access(pathToCheck, fs_1.default.constants.F_OK, (err) => { | ||
if (err) { | ||
return resolve(false); | ||
} | ||
return resolve(true); | ||
}); | ||
}); | ||
/** | ||
* Empties given folder by removing it and creating it again | ||
* @param {string} folderPath Folder path to be emptied | ||
*/ | ||
exports.emptyFolder = async (folderPath) => { | ||
const pathExists = await exports.exists(folderPath); | ||
if (pathExists) { | ||
await exports.rimraf(folderPath); | ||
} | ||
await exports.mkDir(folderPath, { recursive: true }); | ||
}; | ||
/** | ||
* Ensures that given dir path exists | ||
* @param {string} folderPath Path to ensure | ||
* @param {fs.MakeDirectoryOptions} options Options | ||
*/ | ||
exports.ensureDir = async (folderPath, options, recursive = true) => { | ||
await new Promise((resolve, reject) => { | ||
fs_1.default.mkdir(folderPath, Object.assign(Object.assign({}, (options || {})), { recursive }), (err) => { | ||
if (err && err.code !== 'EEXIST') { | ||
reject(err); | ||
} | ||
else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Gets files recursively | ||
* @param folderPath Path to get files from | ||
* @param extName Extension names to filter files (including `.`) | ||
*/ | ||
exports.getFilesRecursively = async (folderPath, extName) => { | ||
const contents = await exports.readDir(folderPath, { | ||
encoding: 'utf8', | ||
withFileTypes: true, | ||
}); | ||
const files = await Promise.all(contents.map(async (content) => { | ||
if (content.isDirectory()) { | ||
const folderFiles = await exports.getFilesRecursively(path_1.default.resolve(folderPath, content.name), extName); | ||
return folderFiles; | ||
} | ||
const ext = path_1.default.extname(content.name); | ||
if (!extName || !extName.length || extName.indexOf(ext) !== -1) { | ||
return [path_1.default.resolve(folderPath, content.name)]; | ||
} | ||
return []; | ||
})); | ||
return files.reduce((t, f) => [...t, ...f], []); | ||
}; | ||
/** | ||
* Copies contents recursively from `fromPath` to `destPath` | ||
* @param {string} fromPath Source path | ||
* @param {string} destPath Destination path | ||
* @param {string} [relativePath=''] Relative path | ||
*/ | ||
exports.copyContents = async (fromPath, destPath, hard = true, relativePath = '') => { | ||
const contentsPath = path_1.default.resolve(fromPath, relativePath); | ||
await exports.ensureDir(destPath); | ||
const contents = await exports.readDir(contentsPath, { withFileTypes: true }); | ||
await Promise.all(contents.map(async (pathInfo) => { | ||
const { name: relPath } = pathInfo; | ||
const fullRelPath = path_1.default.join(relativePath, relPath); | ||
const sourcePath = path_1.default.resolve(fromPath, fullRelPath); | ||
const targetPath = path_1.default.resolve(destPath, fullRelPath); | ||
if (pathInfo.isDirectory()) { | ||
await exports.ensureDir(targetPath); | ||
await exports.copyContents(fromPath, destPath, hard, fullRelPath); | ||
} | ||
else { | ||
const write = hard || !(await exports.exists(targetPath)); | ||
if (write) { | ||
await exports.copyFile(sourcePath, targetPath); | ||
} | ||
} | ||
})); | ||
}; | ||
//# sourceMappingURL=fs.js.map</code></pre> | ||
</article> | ||
</section> | ||
|
||
|
||
|
||
|
||
</div> | ||
|
||
<footer class="footer"> | ||
<div class="content has-text-centered"> | ||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.4</a></p> | ||
<p class="sidebar-created-by"> | ||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by | ||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a> | ||
</p> | ||
</div> | ||
</footer> | ||
|
||
</div> | ||
<div id="side-nav" class="side-nav"> | ||
</div> | ||
</div> | ||
<script src="scripts/app.min.js"></script> | ||
<script>PR.prettyPrint();</script> | ||
<script src="scripts/linenumber.js"> </script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.