How to use the node-dir.subdirs function in node-dir

To help you get started, we’ve selected a few node-dir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 1j01 / retrores / extract-resources.js View on Github external
const extractResourcesToCorrespondingDirectoryStructure = (sourceRootPath, destinationRootPath)=> {
	console.log(`Extracting resources from: ${sourceRootPath}`);

	dir.subdirs(sourceRootPath, (err, sourceSubDirectoryPaths)=> {
		if (err) { throw err; }
		const sourceDirectoryPaths = [sourceRootPath].concat(sourceSubDirectoryPaths);

		mapLimit(sourceDirectoryPaths, 1,
			(sourceDirectoryPath, callback)=> {
				const sharedPath = path.relative(sourceRootPath, sourceDirectoryPath);
				const destinationDirectoryPath = path.join(destinationRootPath, sharedPath);
				mkdirp.sync(destinationDirectoryPath);
				resourcesExtract(sourceDirectoryPath, destinationDirectoryPath, (err)=> {
					if (err) { return callback(err); }
					fs.readdir(sourceDirectoryPath, (err, sourceFnames)=> {
						if (err) { return callback(err); }
						fs.readdir(destinationDirectoryPath, (err, destinationFnames)=> {
							if (err) { return callback(err); }
							// resultantResourceFnames = fnames;
							// may include directories; i'm assuming they won't match for now
github icfnext / iron / lib / operations / create-project.js View on Github external
clientLibs( function( libs ){

                if( libs.length !== 0 ){
                    var clientlibsPath      = libs[0].path.split( "/" );
                    config.clientlib_root   = clientlibsPath
                                                .splice( 0, clientlibsPath.indexOf('clientlibs') + 2 )
                                                .join('/');

                    fs.writeFileSync( '.ironrc' , JSON.stringify( config, null, 4 ));
                } else {
                    var nodeDir = require('node-dir');
                    nodeDir.subdirs(shell.pwd().stdout, function (err, subdirs) {
                        // Files is an array of filename

                        var index = subdirs.findIndex( function( filePath ){
                            var pathArray   = filePath.split('/');
                            var foundAt     = pathArray.indexOf("clientlibs");

                            return (foundAt !== -1);
                        } );


                        if( subdirs[index] === undefined ){

                            var etcIndex = subdirs.findIndex( function( filePath ){
                                var pathArray   = filePath.split('/');
                                var foundAt     = pathArray.indexOf("etc");
github icfnext / iron / dist / operations / create-project.js View on Github external
clientLibs(function (libs) {

                if (libs.length !== 0) {
                    var clientlibsPath = libs[0].path.split("/");
                    config.clientlib_root = clientlibsPath.splice(0, clientlibsPath.indexOf('clientlibs') + 2).join('/');

                    fs.writeFileSync('.ironrc', JSON.stringify(config, null, 4));
                } else {
                    var nodeDir = require('node-dir');
                    nodeDir.subdirs(shell.pwd().stdout, function (err, subdirs) {
                        // Files is an array of filename

                        var index = subdirs.findIndex(function (filePath) {
                            var pathArray = filePath.split('/');
                            var foundAt = pathArray.indexOf("clientlibs");

                            return foundAt !== -1;
                        });

                        if (subdirs[index] === undefined) {

                            var etcIndex = subdirs.findIndex(function (filePath) {
                                var pathArray = filePath.split('/');
                                var foundAt = pathArray.indexOf("etc");

                                return foundAt !== -1;
github linzhixian / quick-vue-admin / src / server / meta / indexServer.js View on Github external
var dir = require('node-dir');
const path=require("path")

let map = {};

dir.subdirs(__dirname, function(err, subdirs) {
    if (err) throw err;
    for(let oneDir of subdirs) {
        let dirName=path.basename(oneDir)        
        loadDir(dirName,path.join(__dirname,dirName))        
    }
});

function loadDir(moduleName,dirPath) {
    dir.files(dirPath, function(err, files) {
     if (err) throw err;
     for(let oneFile of files) {        
        let key=path.basename(oneFile,".js")        
          console.log("server loaded:" + "/" + moduleName + "/" + key);
           map["/" + moduleName + "/" + key] = require(oneFile)
        
    }
github shershen08 / vue-styleguide-generator / src / walker.js View on Github external
const getSubDirsList = (dirPath) => {
  var dfd = Q.defer()

  dir.subdirs(dirPath, function (err, subdirs) {
    if (err) throw err
    dfd.resolve(subdirs)
  })
  return dfd.promise
}
const readFlatFiles = (dirPath) => {
github fireflylearning / pattern-library / src / gulp-tasks / fileInfo.js View on Github external
return function(callback) {
        var processSubdir = getBlockSubdirProcess(dataStore, options),
            processSubdirComplete = getProcessSubdirComplete(dataStore, callback);

        dir.subdirs(fileSrc, getSubDirIterator(processSubdir, processSubdirComplete, options));
    };
}

node-dir

asynchronous file and directory operations for Node.js

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis