{"id":19778313,"url":"https://github.com/npkgz/fs-magic","last_synced_at":"2026-02-10T09:07:03.912Z","repository":{"id":40745583,"uuid":"88501652","full_name":"npkgz/fs-magic","owner":"npkgz","description":":floppy_disk: An extended, promisified fs drop-in-replacement for Node.js \u003e=7.6","archived":false,"fork":false,"pushed_at":"2023-07-19T02:38:56.000Z","size":240,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-27T06:46:50.436Z","etag":null,"topics":["async","asynchronous","await","copy","es2017","extension","mkdirp","nodejs","untar"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fs-magic","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npkgz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-17T11:25:35.000Z","updated_at":"2024-09-01T07:27:58.000Z","dependencies_parsed_at":"2024-06-19T17:39:39.018Z","dependency_job_id":"918fed8f-a983-42f3-aab2-460b1fcddaa6","html_url":"https://github.com/npkgz/fs-magic","commit_stats":null,"previous_names":["andidittrich/node.fs-magic"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/npkgz/fs-magic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Ffs-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Ffs-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Ffs-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Ffs-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npkgz","download_url":"https://codeload.github.com/npkgz/fs-magic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Ffs-magic/sbom","scorecard":{"id":112688,"data":{"date":"2025-08-04","repo":{"name":"github.com/npkgz/fs-magic","commit":"8fa64a18f5cb84984db52d134605eeb0ac18ddf5"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":1.7,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"10 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T13:48:44.028Z","repository_id":40745583,"created_at":"2025-08-15T13:48:44.029Z","updated_at":"2025-08-15T13:48:44.029Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29295459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T03:42:42.660Z","status":"ssl_error","status_checked_at":"2026-02-10T03:42:41.897Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asynchronous","await","copy","es2017","extension","mkdirp","nodejs","untar"],"created_at":"2024-11-12T05:28:53.212Z","updated_at":"2026-02-10T09:07:03.889Z","avatar_url":"https://github.com/npkgz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/AndiDittrich/Node.fs-magic.svg?branch=master)](https://travis-ci.org/AndiDittrich/Node.fs-magic)\n\nfs-magic\n=========================\n\nAn extended, promisified **fs** drop-in-replacement for Node.js **\u003e=7.6**\n\nFeatures\n------------------------------\n\n* All asynchronous **fs** functions are and converted into promises with **async-magic**\n* Lot of extended functions are added\n* Designed to run with the pure power of native `Promise`, `await` and `async function`\n* No backward compatibility layer\n* OS Support for POSIX and Win Platforms (as of v1.3.0)\n* Streams, Streams, Streams - all file operations are stream-based!\n\nAddons\n------------------------------\n\n* **copy** Just copy a file (stream based)\n* **bulkCopy** Copy multiple files/directories in once\n* **mkdirp** Create directories recursivly\n* **scandir** List all files + directories of given directory recursivly\n* **rmrf** Removes all files of a given directory recursivly\n* **exists** Custom `exists` function to test file existence\n* **isFile** Check if item is a file\n* **isDirectory** Check if item is a directory\n* **isSymlink** Check if item is a symlink\n* **isSocket** Check if item is a socket\n* **isFileOfType** Check if item is of specific type\n* **FileInputStream** Open a new fileReadStream\n* **FileOutputStream** Write stream to destination file\n* **untar** Extracting `.tar` archives using **tar-stream**\n* **untgz** Extracting gzip compressed `.tar` archives\n* **gzip** Compress a file\n* **gunzip** Decompress a file\n* **sha1file** SHA1 File Checksum\n* **sha256file** SHA256 File Checksum\n* **sha384file** SHA384 File Checksum\n* **sha512file** SHA512 File Checksum\n* **md5file** MD5 File Checksum\n* **checksum** Generic File Checksum\n* **statx** Silent stat (returns false in case of ENOENT)\n\nPromisified FS API\n------------------------------\n\nThe following asynchronous `fs` methods are promisified and exposed within the `fs-magic` object. All synchronous functions are ignored because there is no need for them anymore - use `await`!\n\n* **access**\n* **appendFile**\n* **chmod**\n* **chown**\n* **close**\n* **fchmod**\n* **fchown**\n* **fdatasync**\n* **fstat**\n* **fsync**\n* **ftruncate**\n* **futimes**\n* **lchown**\n* **link**\n* **lstat**\n* **mkdir**\n* **mkdtemp**\n* **open**\n* **read**\n* **readFile**\n* **readdir**\n* **readlink**\n* **realpath**\n* **rename**\n* **rmdir**\n* **stat**\n* **symlink**\n* **truncate**\n* **unlink**\n* **utimes**\n* **write**\n* **writeFile**\n\nGeneral Usage\n------------------------------\n\n```js\nconst _fsm = require('fs-magic');\n\n// wraper \n(async function(){\n    // get stats\n    const stats= await _fsm.fstat('myfile.js');\n\n    // does the file exists ?\n    console.log(await _fsm.exists('myfile.js'));\n\n    // copy a file, set chmod to 0640\n    await _fsm.copy('test1.js', 'test2.js', 0o640);\n\n    // create directory stucture at once\n    await _fsm.mkdirp('my/custom/dir/1/2/3', 0o777, true);\n\n    // use fs methods\n    await _fsm.rmdir('mydir');\n})();\n```\n\nfs-magic::copy\n---------------------------------\n\n**Description:** Copy a single file\n\n**Syntax:** `copy(sourcefile:string, destinationfile:string, mode:int=null)`\n\n**Example:**\n\n```js\n// copy a file, set chmod to 0640\nawait _fsm.copy('test1.js', 'test2.js', 0o640);\n```\n\n\nfs-magic::bulkCopy\n---------------------------------\n\n**Description:** Copy multiple files at once\n\n**Syntax:** `bulkCopy(srcset:Array, createDestinationDirs:boolean=true, defaultFilemode:int=0o750, defaultDirmode:int=0o777)`\n\n**Example:**\n\n```js\n// list of files to copy\nconst srcset = [\n    ['source/file1.js', 'destination/subdir/file1.js', 0o644],\n    ['source/file2.js', 'destination/subdir/file2.js', 0o644],\n    ['source/file3.js', 'destination/subdir/x/file3.js', 0o644],\n    ['source/file4.js', 'destination/subdir/x/file4.js', 0o644],\n];\n\n// copy files + create destination directories\nawait _fsm.bulkCopy(srcset, true);\n\n```\n\nfs-magic::mkdirp\n---------------------------------\n\n**Description:** Create a directories recusivly\n\n**Syntax:** `mkdirp(directory:string, mode:int=0o777, recursive:boolean=false)`\n\n**Example:**\n\n```js\n// create directory stucture at once\nawait _fsm.mkdirp('my/custom/dir/1/2/3', 0o777, true);\n```\n\nfs-magic::scandir\n---------------------------------\n\n**Description:** List all files + directories of given directory recursivly (optional)\n\n**Syntax:** `scandir(directory:string, recursive:boolean=true, absolutePaths:boolean=false)`\n\n**Example:**\n\n```js\n// get file + directory list of all files. Use absolute output paths\nconst [files, dirs] = await _fs.scandir('project/modules', true, true);\n```\n\nfs-magic::rmrf\n---------------------------------\n\n**Description:** Removes all files of a given directory recursivly\n\n**Syntax:** `rmrf(directory:string)`\n\n**Note:** For security reasons, this function **does not** accept the file system root `/` or a directory within it like `/etc` as input \n\n**Example:**\n\n```js\n// remove a project folder\nawait _fs.rmrf('projects/js1');\n```\n\nfs-magic::exists\n---------------------------------\n\n**Description:** Check if a file/directory/link exists\n\n**Syntax:** `exists(filedir:string)`\n\n**Example:**\n\n```js\n// does the file exists ?\nconsole.log(await _fsm.exists('myfile.js'));\n```\n\nfs-magic::isFile\n---------------------------------\n\n**Description:** Check if a item is of type file\n\n**Syntax:** `isFile(filesystemItem:string)`\n\n**Example:**\n\n```js\n// is a file ?\nconsole.log(await _fsm.isFile('myfile.js'));\n```\n\nfs-magic::isDirectory\n---------------------------------\n\n**Description:** Check if a item is of type directory\n\n**Syntax:** `isDirectory(filesystemItem:string)`\n\n**Example:**\n\n```js\n// is a directory ?\nconsole.log(await _fsm.isDirectory('/var/log'));\n```\n\nfs-magic::isSocket\n---------------------------------\n\n**Description:** Check if a item is of type socket\n\n**Syntax:** `isSocket(filesystemItem:string)`\n\n**Example:**\n\n```js\n// is a socket ?\nconsole.log(await _fsm.isSocket('/var/run/phpfpm.sock'));\n```\n\nfs-magic::isSymlink\n---------------------------------\n\n**Description:** Check if a item is of type symlink\n\n**Syntax:** `isSymlink(filesystemItem:string)`\n\n**Example:**\n\n```js\n// is a symlink ?\nconsole.log(await _fsm.isSymlink('/etc/motd'));\n```\n\nfs-magic::isFileOfType\n---------------------------------\n\n**Description:** Check if a item is of specific type\n\n**Syntax:** `isFileOfType(filename:string, condition:function)`\n\n**Example:**\n\n```js\n// check if node is socket\nasync function isSocket(filename){\n    return await _fsm.isFileOfType(filename, (stats) =\u003e stats.isSocket());\n};\n```\n\nfs-magic::FileInputStream\n---------------------------------\n\n**Description:** Open a fileStream for read\n\n**Syntax:** `FileInputStream(sourcefile:string)`\n\n**Example:**\n\n```js\nconst _fsm = require('fs-magic');\n\n// copy source file to destination (override it)\nasync function copy(src, dst, mode=null){\n    // open file input stream\n    const istream = await _fsm.FileOutputStream(src);\n\n    // write stream content to file\n    return _fsm.FileOutputStream(istream, dst, mode);\n}\n```\n\nfs-magic::FileOutputStream\n---------------------------------\n\n**Description:** Writes given stream into file\n\n**Syntax:** `FileOutputStream(readstream:stream, destinationFilename:string, mode:int=false)`\n\n**Example:**\n\n```js\nconst _fsm = require('fs-magic');\nconst _fetch = require('node-fetch');\n\n// fetch remote content\nconst response = await _fetch('http://example.org/file.gz');\n\n// write stream content to file\nawait _fsm.FileOutputStream(response.body, dst, mode);\n```\n\nfs-magic::untar\n---------------------------------\n\n**Description:** Extracts contents of a `.tar` archive into given directory using **tar-stream**\n\n**Syntax:** `untar(inputstream:stream, destinationDirectory:string)`\n\n**Example:**\n\n```js\nconst _fetch = require('node-fetch');\nconst _fsm = require('fs-magic');\n\n// fetch remote content\nconst response = await _fetch('http://example.org/file.tar');\n\n// unpack into currrent directory\nlet items = await _fsm.untar(response.body, '.');\n```\n\nfs-magic::untgz\n---------------------------------\n\n**Description:** Extracts contents of a gzip compressed `.tar.gz` archive into given directory using **tar-stream**\n\n**Syntax:** `untgz(inputstream:stream, destinationDirectory:string)`\n\n**Example:**\n\n```js\nconst _fetch = require('node-fetch');\n\n// fetch remote content\nconst response = await _fetch('http://example.org/file.tar.gz');\n\n// unpack into currrent directory\nlet items = await _fsm.untgz(response.body, '.');\n```\n\nfs-magic::gzip\n---------------------------------\n\n**Description:** Compresses a file\n\n**Syntax:** `gzip(input:{string, stream}, destinationFilename:string)`\n\n**Example:**\n\n```js\n// compress a file\nawait _fsm.gzip('./file.txt', './file.gz');\n```\n\nfs-magic::gunzip\n---------------------------------\n\n**Description:** Decompresses a file\n\n**Syntax:** `gunzip(input:{string, stream}, destinationFilename:string)`\n\n**Example:**\n\n```js\n// decompress a file\nawait _fsm.gunzip('./file.gz', './my-file.txt');\n```\n\n```js\n// fetch content\nconst response = await _fetch('http://example.org/file.gz');\n\n// decompress a stream\nawait _fsm.gunzip(response.body, './file.txt');\n```\n\nfs-magic::checksum\n---------------------------------\n\n**Description:** Generic File Checksum\n\n**Syntax:** `checksum(filename:string, algorithm:string='sha256', outputFormat:string='hex')`\n\n**Example:**\n\n```js\n// sha384 checksum as base64\nconst sum = await _fsm.checksum('./file.txt', 'sha384', 'base64');\n```\n\nfs-magic::sha1file\n---------------------------------\n\n**Description:** SHA1 File Checksum\n\n**Syntax:** `sha1file(filename:string, outputFormat:string='hex')`\n\n**Example:**\n\n```js\n// sha1 checksum as hex\nconst sum = await _fsm.sha1file('./file.txt');\n```\n\nfs-magic::sha256file\n---------------------------------\n\n**Description:** SHA256 File Checksum\n\n**Syntax:** `sha256file(filename:string, outputFormat:string='hex')`\n\n**Example:**\n\n```js\n// sha256 checksum as hex\nconst sum = await _fsm.sha256file('./file.txt');\n```\n\nfs-magic::sha384file\n---------------------------------\n\n**Description:** SHA384 File Checksum\n\n**Syntax:** `sha384file(filename:string, outputFormat:string='hex')`\n\n**Example:**\n\n```js\n// sha384 checksum as buffer\nconst sum = await _fsm.sha384file('./file.txt', 'raw');\n```\n\nfs-magic::sha512file\n---------------------------------\n\n**Description:** SHA512 File Checksum\n\n**Syntax:** `sha512file(filename:string, outputFormat:string='hex')`\n\n**Example:**\n\n```js\n// sha512 checksum as base64\nconst sum = await _fsm.sha512file('./file.txt', 'base64');\n```\n\nfs-magic::statx\n---------------------------------\n\n**Description:** Extended `stat` function. The function retuns **false** in case of ENOENT error (file not found)\n\n**Syntax:** `statx(filesystemItem:string)`\n\n**Example:**\n\n```js\n// get file stats ?\nconst stats = await _fsm.statx('/var/log/unknown_file.log');\n\nif (stats !== false){\n    console.log(stats);\n}\n```\n\nAny Questions ? Report a Bug ? Enhancements ?\n---------------------------------------------\nPlease open a new issue on [GitHub](https://github.com/AndiDittrich/Node.fs-magic/issues)\n\nLicense\n-------\nfs-magic is OpenSource and licensed under the Terms of [The MIT License](LICENSE.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Ffs-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpkgz%2Ffs-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Ffs-magic/lists"}