dist |
src |
.editorconfig |
.eslintrc.js |
.prettierignore |
.prettierrc |
CHANGELOG.md |
README.md |
jest.config.setup.js |
package.json |
yarn.lock |
file helpers for reading, writing, deleting, checking types & existence, extracting metadata, walking, globbing, and more.
yarn add flipfile npm i flipfile --save
const flipfile = require('flipfile')
(file: stringPath) => {file: string, dir: string}
(src: string, blacklist: Array<string>) => array<string>
(file: stringPath) => boolean
(file: stringPath) => boolean
(file: stringPath) => boolean
(file: stringPath) => boolean
(dir: stringPath) => string
(file: stringPath, contents: string) => void
writes to folder, uses mkdir if it does not exist(file: stringPath) => boolean
(file: stringPath) => string
(file: stringPath) => bool
(dir: stringPath, {recursive: true}) => Array<string | Array<Array<string>>
everything in #api is exported in the main entry point, so it can be used as
const {exists, isFile} = require('flipfile') const file = './index.js' if (exists(file)) console.log(read(file))
or as modular imports for fastest / smallest access
const isRel = require('flipfile/isRel') const write = require('flipfile/write') const file = './src' if (isRel(file)) write(file, 'eh')
additionally there are 3 files not exported in the index
flipfile/all
path
modulerequire('flipfile/glob')
require('flipfile/extra')
extra
is exported flat as wellrequire('flipfile/glob')
const { extra, // fs-extra module promise, // fs-promise or empty object exists, // flipfile.exists copySync, // flat export from fs-extra glob, // glob-fs fs, // real 'fs' resolve, // flat export from path join, // flat export from path } = require('flipfile/all') const out = resolve(__dirname, './out') const src = resolve(__dirname, './src') if (exists(src)) { glob(src).forEach(fileOrDir => { copySync(fileOrDir, join(out, fileOrDir)) }) }
const flipfile = require('flipfile') flipfile .file('./file') .isRel() .exists() .write('contents') .del() .exists()