Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
create-tree
Advanced tools
Create-tree is a tool that helps us to create a working directory.
Once you install create-tree through npm, you can use the create-tree
command in npm script.
Add create-tree to you npm script command.
package.json:
{
"scripts": {
"ctree": "create-tree",
}
}
Also, you need to provide a ctree.config.js in root path.
ctree.config.js:
let folder = {
'page': {
'module': {
'mod': {},
'utils': {},
'preloadindex.inline': 'js',
'firstscreenindex.inline': 'js',
'index.async': 'js',
'index': 'shtml'
}
}
}
module.exports = {folder}
Then, just run npm run ctree
, you will create a directory structure in root path like this:
update
let folder = {
'index': ['html', 'css', 'js']
}
module.exports = {folder}
All configurations of create-tree are written in ctree.config.js.This config file should put in where you want to create this directory structure and run create-tree npm script command.
Every ctree.config.js should exports the folder object to specify the directory structure that you want to create.
In folder object:
ctree.config.js:
let folder = {
'modules': {},
'index': 'js'
}
module.exports = {folder}
With the configuration above, we can create a folder named 'modules' and index.js in current path.
Also, if the folder or file already exists, create-tree will skip them.
You can replace some folders or files's name when running the npm script, the only thing you need to do is to provide the replacement arguments.
ctree.config.js:
let folder = {
'src': {
'pages': {
'modules': {}
}
}
}
module.exports = {folder}
If you want to replace folder's name from 'module' to 'index' dynamically, you just need to provide an arguments to npm script like this:
npm run ctree -- "src.pages.modules:index"
Like the example above, sometimes the item we want to replace is very deep. It's very boring to tap a long string like "src.pages.modules:index" everytime.
Create-tree has a alias function to avoid that by exports an alias Object.
ctree.config.js:
let folder = {
'src': {
'pages': {
'modules': {}
}
}
}
module.exports = {
folder: folder,
alias: {
module: 'src.page.module'
}
}
Then, we can replace 'module' to 'index' like this:
npm run ctree -- --module index
Actually, you can let this command shorter using the npm script.
You can provide some file's templates in folder: ctree_tpl, then specify which file need this template to generate its' content.
Notice that the file and its' template must has a same name and ext.
ctree.config.js:
let folder = {
'page': {
'module': {
'index': 'shtml'
}
}
}
module.exports = {
folder: folder,
templates: [
"/page/module/index.shtml"
]
}
Notice: the nodejs version must >= 6.0.0
With npm:
npm install create-tree
FAQs
Help to creating a work dir tree.
The npm package create-tree receives a total of 10 weekly downloads. As such, create-tree popularity was classified as not popular.
We found that create-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.