npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mkfiles

v1.6.1

Published

Batch create module directories and files!

Downloads

32

Readme

mkfiles

mkfiles mkfiles mkfiles version mkfiles donwloads

mkfiles

Introduction:mkfiles is a npm package, it is use for batch create module directories and files.

1. Install

(sudo) npm install mkfiles

2. API

(1) mkfiles(config)

* param: config

* type: Object | Array
    
* options:
    
    * path -- <String>, <required>, base path, etc: './src/mods/'
        
    * dirs -- <Array>, <optional>, directory list, etc: ['test', 'demo']
        
    * files -- <Array>, <required>, file list, etc:
        
        [
            'index.css', 
            {
                file: 'filename', 
                content: String | Object 
            }
        ]

3. Usage

(1) Create a module directory, and create files in the directory.

var mkfiles = require('mkfiles');
var baseDir = './src/mods/';

mkfiles({
    path: baseDir + 'exam1',
    files: ['a.txt', 'b.txt']
});

result:
    ./src/mods/
        -- exam1
            -- a.txt
            -- b.txt

(2) Create a module directory, and create files in the directory, then set up file content.

mkfiles({
    path: baseDir,
    dirs: ['exam2'],
    files: [
        {
            file: 'a.txt',
            content: 'default content'  // specify the content directly
        },
        {
            file: 'b.txt',
            content: {
                template: 'My name is {{name}}',  // specify the content by template string(only support handlebars)
                data: {name: 'haha'}
            }
        },
        {
            file: 'c.txt',
            content: {
                template: 'template.handlebars', // specify the content by template file(only support handlebars), file content is 'My name is {{name}}'
                data: {name: 'haha'}
            }
        }
    ]
});

result:
    ./src/mods/
        -- exam2
            -- a.txt  // The file content is 'default content'
            -- b.txt  // The file content  is ’My name is haha'
            -- c.txt  // The file content  is ’My name is haha'

(3) Create multiple module directories at the same time, and create files in the directory.

mkfiles([{
    path: baseDir,
    dirs: ['exam3'],
    files: ['a.txt']
}, {
    path: baseDir,
    dirs: ['exam4'],
    files: ['b.txt']
}]);

result:
    ./src/mods/
        -- exam3
            -- a.txt
        -- exam4
            -- b.txt

(4) Create multiple module directories at the same time, and create same files for each directory.

mkfiles({
    path: baseDir,
    dirs: ['exam5', 'exam6'],
    files: ['a.txt', 'b.txt']
});

result:
    ./src/mods/
        -- exam5
            -- a.txt
            -- b.txt
        -- exam6
            -- a.txt
            -- b.txt

(5) Create a module contains subdirectories, and create the same file for each subdirectory.

mkfiles({
    path: baseDir + 'exam7',
    dirs: ['desktop', 'tablet', 'mobile'],
    files: ['index.js', 'index.css', 'index.tpl.html']
});

result:
    ./src/mods/
        -- exam7
            -- desktop
                -- index.js
                -- index.css
                -- index.tpl.html
            -- tablet
                -- index.js
                -- index.css
                -- index.tpl.html
            -- mobile
                -- index.js
                -- index.css
                -- index.tpl.html