Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@jsenv/filesystem
Advanced tools
Collection of functions to interact with filesystem in Node.js.
@jsenv/filesystem
provides functions needed to work with files. It has no external dependency.
The whole list of functions exported by @jsenv/filesystem
are documented in ./docs/API.md. This section demonstrates how @jsenv/filesystem
can be used in common use cases.
import { urlToRelativeUrl } from "@jsenv/filesystem"
const projectDirectoryUrl = "file:///project/"
const jsFileUrl = "file:///project/src/file.js"
const relativeUrl = urlToRelativeUrl(jsFileUrl, projectDirectoryUrl) // "src/file.js"
import { collectFiles } from "@jsenv/filesystem"
const jsAndSourceMapFiles = await collectFiles({
directoryUrl: "file:///project/directory/",
structuredMetaMap: {
isJsFile: {
"./**/*.js": true,
},
isSourceMapFile: {
"./**/*.js.map": true,
},
},
predicate: ({ isJsFile, isSourceMapFile }) => isJsFile || isSourceMapFile,
})
console.log(jsAndSourceMapFiles.length)
import { readFileSync } from "node:fs"
import { registerFileLifecycle } from "@jsenv/filesystem"
const packageJSONFileUrl = new URL("./package.json", import.meta.url)
let packageJSON = null
const unregister = registerFileLifecycle(packageJSONFileUrl, {
added: () => {
packageJSON = JSON.parse(String(readFileSync(filePath)))
},
updated: () => {
packageJSON = JSON.parse(String(readFileSync(filePath)))
},
removed: () => {
packageJSON = null
},
notifyExistent: true,
})
unregister() // stop watching the file changes
import { registerDirectoryLifecycle } from "@jsenv/filesystem"
const contentMap = {}
const unregister = registerDirectoryLifecycle("file:///directory/", {
watchDescription: {
"./**/*": true,
"./node_modules/": false,
},
added: ({ relativeUrl, type }) => {
contentMap[relativeUrl] = type
},
removed: ({ relativeUrl }) => {
delete contentMap[relativeUrl]
},
})
unregister() // stop watching the directory changes
npm install @jsenv/filesystem
If you are part or want to be part of the developpers of this package, check docs/development.md
31.0.0
FAQs
Collection of functions to interact with filesystem in Node.js
The npm package @jsenv/filesystem receives a total of 3 weekly downloads. As such, @jsenv/filesystem popularity was classified as not popular.
We found that @jsenv/filesystem demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.