Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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");
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;
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)
}
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) => {
return function(callback) {
var processSubdir = getBlockSubdirProcess(dataStore, options),
processSubdirComplete = getProcessSubdirComplete(dataStore, callback);
dir.subdirs(fileSrc, getSubDirIterator(processSubdir, processSubdirComplete, options));
};
}