All Projects → electerious → fsify

electerious / fsify

Licence: MIT license
Convert an array of objects into a persistent or temporary directory structure.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fsify

gtree
Output tree🌳 or Make directories📁 from #Markdown or Programmatically. Provide CLI, Golang library and Web (using #Wasm ).
Stars: ✭ 88 (+266.67%)
Mutual labels:  tree, filesystem, directory, file
directory-structure
📦 Print a directory tree structure in your Python code.
Stars: ✭ 40 (+66.67%)
Mutual labels:  tree, directory, structure, file
Tree Node Cli
🌲 Node.js library to list the contents of directories in a tree-like format, similar to the Linux tree command
Stars: ✭ 102 (+325%)
Mutual labels:  tree, directory, file
files
Useful methods to manage files and directories
Stars: ✭ 27 (+12.5%)
Mutual labels:  filesystem, directory, file
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+11062.5%)
Mutual labels:  filesystem, file
Aiofile
Real asynchronous file operations with asyncio support.
Stars: ✭ 214 (+791.67%)
Mutual labels:  filesystem, file
gitree
Print a directory tree that shows Git status and ignores files dictated by .gitignore.
Stars: ✭ 32 (+33.33%)
Mutual labels:  tree, directory
File Storage
File storage abstraction for Yii2
Stars: ✭ 116 (+383.33%)
Mutual labels:  filesystem, file
Coc Explorer
📁 Explorer for coc.nvim
Stars: ✭ 722 (+2908.33%)
Mutual labels:  tree, file
Repository Tree
🌲Pretty display directory tree view of a GitHub repository.
Stars: ✭ 56 (+133.33%)
Mutual labels:  tree, directory
fileutils
Golang file system utils such as copy files and directories
Stars: ✭ 19 (-20.83%)
Mutual labels:  filesystem, file
Filehound
Flexible and fluent interface for searching the file system
Stars: ✭ 190 (+691.67%)
Mutual labels:  filesystem, file
Filesystem
FileSystem is an application that allows you to browse the content of your iPhone disk, displaying file and folders, files contents, and detailed informations about file and folder permissions.
Stars: ✭ 148 (+516.67%)
Mutual labels:  filesystem, file
Renamer
Rename files in bulk.
Stars: ✭ 240 (+900%)
Mutual labels:  filesystem, file
Flametree
🔥 Python file and zip operations made easy
Stars: ✭ 148 (+516.67%)
Mutual labels:  filesystem, file
dirgen
Generate files and folders from a template file
Stars: ✭ 21 (-12.5%)
Mutual labels:  directory, structure
FileRenamerDiff
A File Renamer App featuring a difference display before and after the change.
Stars: ✭ 32 (+33.33%)
Mutual labels:  filesystem, file
Filesize.js
JavaScript library to generate a human readable String describing the file size
Stars: ✭ 997 (+4054.17%)
Mutual labels:  filesystem, file
Hypertag
Knowledge Management for Humans using Machine Learning & Tags
Stars: ✭ 116 (+383.33%)
Mutual labels:  filesystem, file
Jstarcraft Ai
目标是提供一个完整的Java机器学习(Machine Learning/ML)框架,作为人工智能在学术界与工业界的桥梁. 让相关领域的研发人员能够在各种软硬件环境/数据结构/算法/模型之间无缝切换. 涵盖了从数据处理到模型的训练与评估各个环节,支持硬件加速和并行计算,是最快最全的Java机器学习库.
Stars: ✭ 160 (+566.67%)
Mutual labels:  tree, structure

fsify

Build Coverage Status

Convert an array of objects into a persistent or temporary directory structure.

Contents

Description

fsify creates a persistent or temporary directory structure from an array of objects. It's like the opposite of the Linux and Unix tree command.

Install

npm install fsify

Usage

Structure with content

.
├── dirname
│   └── filename
└── filename
const fsify = require('fsify')()

const structure = [
	{
		type: fsify.DIRECTORY,
		name: 'dirname',
		contents: [
			{
				type: fsify.FILE,
				name: 'filename',
				contents: 'data'
			}
		]
	},
	{
		type: fsify.FILE,
		name: 'filename',
		contents: 'data'
	}
]

fsify(structure)
	.then((structure) => console.log(structure))
	.catch((error) => console.error(error))

Deeply nested structure

.
└── dirname
    └── dirname
        └── filename
const fsify = require('fsify')()

const structure = [
	{
		type: fsify.DIRECTORY,
		name: 'dirname',
		contents: [
			{
				type: fsify.DIRECTORY,
				name: 'dirname',
				contents: [
					{
						type: fsify.FILE,
						name: 'filename'
					}
				]
			}
		]
	}
]

fsify(structure)
	.then((structure) => console.log(structure))
	.catch((error) => console.error(error))

Temporary file in existing directory

dirname/
└── filename
const fsify = require('fsify')({
	cwd: 'dirname/',
	persistent: false
})

const structure = [
	{
		type: fsify.FILE,
		name: 'filename'
	}
]

fsify(structure)
	.then((structure) => console.log(structure))
	.catch((error) => console.error(error))

Structure from tree

tree is a Linux and Unix command that lists the contents of directories in a tree-like format. It's a helpful CLI to view the structure of your file system.

tree -J --noreport ./* > tree.json
const fs = require('fs')
const fsify = require('fsify')()

const structure = require('./tree')

fsify(structure)
	.then((structure) => console.log(structure))
	.catch((error) => console.error(error))

API

Usage

const fsify = require('fsify')()
const fsify = require('fsify')({
	cwd: process.cwd(),
	persistent: true,
	force: false
})

Parameters

  • options {?Object} Options.
    • cwd {?String} - Custom relative or absolute path. Defaults to process.cwd().
    • persistent {?Boolean} - Keep directories and files even when the process exists. Defaults to true.
    • force {?Boolean} - Allow deleting the current working directory and outside. Defaults to false.

Returns

Instance API

Usage

const structure = [
	{
		type: fsify.FILE,
		name: 'filename'
	}
]

fsify(structure)
	.then((structure) => console.log(structure))
	.catch((error) => console.error(error))

Parameters

  • structure {?Array} Array of objects containing information about a directory or file.

Returns

  • {Promise<Array>} A promise that resolves a structure. Equal to the input structure, but parsed and with a absolute path as the name.

Structure

A structure is an array of objects that represents a directory structure. Each object must contain information about a directory or file.

The structure …

.
├── dirname
│   └── filename
└── filename

… is equal to …

[
	{
		type: fsify.DIRECTORY,
		name: 'dirname',
		contents: [
			{
				type: fsify.FILE,
				name: 'filename',
				contents: 'data'
			}
		]
	},
	{
		type: fsify.FILE,
		name: 'filename',
		contents: 'data'
	}
]

Directory

A directory must have the type of a directory and a name. It can also contain another nested structure in its contents and a mode.

{
	type: fsify.DIRECTORY,
	name: 'dirname',
	mode: 0o777,
	contents: []
}

File

A file must have the type of a file and a name. It can also contain contents (data of the file). encoding, mode and flag will be passed directly to fs.writeFile.

{
	type: fsify.FILE,
	name: 'filename',
	contents: 'data',
	encoding: 'utf8',
	mode: 0o666,
	flag: 'w'
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].