console.log('path ? ', getPaths()); 
@constructor

@param {string} bundle
495659
function Proc(bundle, proc, usePidFile){

    var self    = this;
    this.PID    = null;
    this.path   = null;
    this.master = false;//used only by master.
    this.bundle = bundle;
    this.proc   = proc;
    this.bundles = [];

    if ( typeof(usePidFile) == 'undefined') {
        var usePidFile = true
    }

    /**
     * Check target path
     * @param {string} path
     * @param {integer} PID Id of the PID to save
     * */

    var init = function() {
        //Default.
        var pathObj = new _( getPath('root') + '/tmp/pid/' );
        var path = pathObj.toString();

        //Create dir if needed.
        //console.debug("MKDIR  pathObj (pid:"+self.proc.pid+") - ", self.bundle);

        process.list = (process.list == undefined) ? [] : process.list;
        process.pids = (process.pids == undefined) ? {} : process.pids;

        self.register(self.bundle, self.proc.pid);

        if (usePidFile) {
            pathObj.mkdir( function(err, path){
                console.debug('path created ('+path+') now saving PID ' +  bundle);
                //logger.info('gina', 'PROC:INFO:1', 'path created ('+path+') now saving PID ' +  bundle, __stack);
                //Save file.
                if (!err) {
                    self.PID = self.proc.pid;
                    self.path = path + pathObj.sep;
                    //Add PID file.
                    setPID(self.bundle, self.PID, self.proc);
                    save(self.bundle, self.PID, self.proc)
                }
            })
        }
    };

    var isMaster = function() {
        return (self.master) ? true : false;
    };

    // var getShutdownConnectorSync = function(bundle) {
    //     var bundlesPath = getPath('bundlesPath');
    //     var connPath = _(bundlesPath +'/'+ bundle + '/config/connector.json');
    //     try {
    //         console.log('reading connPath: ', connPath);
    //         var content = fs.readFileSync(connPath);
    //         return JSON.parse(content).httpClient.shutdown
    //     } catch (err) {
    //         return undefined
    //     }
    // }
    /**
     * Going to force restart by third party (kill 9).
     *
     * @param {string} bundle
     * @param {string} env
     * @param {number} pid
     *
     * @callback callback
     * @param {boolean|string} err
     * */
    var respawn = function(bundle, env, pid, callback) {
        //var loggerInstance = getContext('logger');
        //loggerInstance["trace"]('Fatal error !');
        //console.debug("Exiting and re spawning : ", bundle, env);
        // TODO - Count the restarts and prevent unilimited loop
        // TODO - Send notification to admin or/and root to the Fatal Error Page.

        var root = getPath('root');
        try {
            var version = process.getVersion(bundle);
        } catch (err) {
            var bundle = process.argv[3];
            //var port = self.getBundlePortByBundleName(bundle);
            //console.log("Bundle ", bundle," already running or port[ "+port+" ] is taken by another process...");
            //loggerInstance["trace"]("Bundle [ "+ bundle +" ] already running or [ "+env+" ] port is use by another process...");
            console.debug("Bundle [ "+ bundle +" ] already running or [ "+env+" ] port is use by another process...");
            dismiss(process.pid);
        }


        var outPath = _(root + '/out.'+bundle+'.'+version+'.log');
        var errPath = _(root + '/out.'+bundle+'.'+version+'.log');
        var nodePath = getPath('node');
        var ginaPath = _(root + '/gina');

        // if (env == 'prod') { //won't loop forever for others env.
        //
        //     //var opt = process.getShutdownConnectorSync();
        //     var opt = getShutdownConnectorSync(bundle);
        //     //Should kill existing one..
        //     opt.path = '/' + bundle + '/restart/' + pid + '/' + env;
        //
        //     var HttpClient = require('gina.com').Http;
        //     var httpClient = new HttpClient();
        //
        //     if (httpClient) {
        //         //httpClient.query(opt);
        //         //We are not waiting for anything particular...do we ?
        //         httpClient.query(opt, function (err, msg) {
        //             //Now start new bundle.
        //             callback(err);
        //         });
        //     } else {
        //         var err = new Error('No shutdown connector found.');
        //         console.error(err);
        //         callback(err);
        //     }
        //
        // } else {
            callback(false);
        //}
    };

    var setPID = function(bundle, PID, proc) {

        if (bundle != 'gina') {
            proc.title = 'gina: '+ bundle;
        } else {
            proc.title = bundle;
        }

        //Set event.
        setDefaultEvents(bundle, PID, proc);
    };

    var setDefaultEvents = function(bundle, PID, proc) {


        if ( typeof(PID) != "undefined" && typeof(PID) == "number" ) {
            console.debug("setting listeners for ", PID, ':', bundle);

            proc.dismiss = dismiss;
            proc.isMaster = isMaster;


            proc.on('SIGTERM', function(code){
                proc.exit(code);
            });

            proc.on('SIGINT', function(code){

                if (code == undefined) var code = 0;
                console.info("\nGot exit code. Now killing: ", code);
                proc.exit(code);//tigger exit event.
            });

            //Will prevent the server from stopping.
            proc.on('uncaughtException', function(err) {

                console.error(err.stack);
                var bundle = self.bundle;
                //console.log("@=>", self.args);
                var env =  process.env.NODE_ENV || 'prod';
                var pid = self.getPidByBundleName(bundle);

                //Wake up buddy !.
                respawn(bundle, env, pid, function(err) {
                    //TODO - Send an email to the administrator/dev
                    //TODO - Have a delegate handler to allow the dev to do its stuff. Maybe it's already there if any dev can override.
                    //proc.exit(1) // don't kill !!! It will stop the server
                })
            });

            proc.on('exit', function(code){

                if ( typeof(code) == 'undefined') {
                    code = 0;
                }

                var bundle = self.bundle;
                var env =  process.env.NODE_ENV || 'prod';
                var pid = self.getPidByBundleName(bundle);

                //console.log('bundle ', bundle, ' vs ', pid, " => ", process.pid);

                //console.log("got exit code ", "("+code+")", pid, " VS ", pid, " <=> gina: ", process.pid);
                //code = code || 0;
                //var obj = logger.emerg('gina', 'UTILS:EMERG1', 'process exit code ' + code);
                //if (code == 0  && env != "debug" && env != "dev"/***/) {

                //for (var p=0; p<process.list.count(); p++) {
                //    dismiss(process.list[p].pid)
                //}

                // kill gina
                dismiss(process.list[process.list.count()-1].pid, "SIGKILL")
            });

            proc.on('SIGHUP', function(code){
                console.debug("Hanging up ! Code: "+ code+"\n"+ process.argv);

                var bundle = self.bundle;
                var env =  process.env.NODE_ENV || 'prod';
                var pid = self.getPidByBundleName(bundle);

                dismiss(process.pid, "SIGINT");
                dismiss(pid, "SIGINT");
            })
        }
    };


    var dismiss = function(pid, signal){
        if (pid == undefined) {
            var pid = self.PID;
        }

        try {

            for (var p in process.list) {
                fs.unlinkSync( _(self.path + process.list[p].pid) )
            }

        } catch (err) {
            //Means that it does not exists anymore.
        }
        try {
            console.debug('\n=> '+ JSON.stringify(process.list, null, 4));
            for (var p in process.list) {
                if ( process.list[p].name != 'gina' ) {
                    fs.unlinkSync( _(getPath('mountPath') + '/'  + process.list[p].name) )
                }
            }
        } catch (err) {
            //Means that it does not exists anymore.
        }

        process.kill(pid, signal);// soft...
        console.debug('\nsent '+ signal +' signal to end process [ '+ pid +' ]\n');
    };

    /**
     * Save PID file
     * @param {string} bundle
     * @param {integer} PID Id of the PID to save
     *
     * @private
     * */
    var save = function(){
        var bundle = self.bundle;
        var PID = self.PID;
        var proc = self.proc;
        var path = self.path
        //Get PID path.
        if (
            typeof(bundle) != "undefined" && bundle != ""
            && typeof(PID) != "undefined" && PID != "" && PID != null
            && typeof(proc) != "undefined" && proc != "" && proc != null
        ) {
            try {
                var fileStream = fs.createWriteStream(path + PID);
                fileStream.once('open', function(fd) {
                    fileStream.write(bundle);
                    console.debug('registered ', self.proc.pid);
                    fileStream.end();
                    self.emit('proc#complete', false)
                });
            } catch (err) {
                self.emit('proc#complete', err)
            }

        } else {
            self.emit('proc#complete', new Error('encountered troubles while trying to save Process file'))
        }
    };


    /**
     * Get PID
     * @param {string} bundle
     * @return {number} PID
     * */
    this.getPID = function(){

        try{
            return self.PID;
        } catch (err) {
            console.error('Could not get PID for bundle: '+ self.bundle + (err.stack||err.message));
            return null;
        }
    };

    this.getBundleNameByPid = function(pid){
        var list = process.list;

        for (var i=0; i<list.length; ++i) {
            //console.log("list ", list, ':',  list[i][pid]);
            if ( typeof(list[i][pid]) != "undefined")
                return list[i][pid]
        }
        return undefined
    };


    this.getPidByBundleName = function(bundle){
        var list = process.pids;
        //console.log("list ", list, ':',  list[bundle]);
        if ( typeof(list[bundle]) != "undefined")
            return list[bundle]
        else
            return undefined
    };

    this.setMaster = function(bool){
        if ( typeof(bool) == 'undefined' || bool == true) {
            self.master = true;
        } else {
            self.master = false;
        }
    };

    this.register = function(bundle, pid) {
        if ( bundle == 'gina' || bundle != 'gina' && self.bundles.indexOf(bundle) == -1 ) {
            if (bundle != 'gina') {
                self.bundles.push(bundle);
            }

            var list = {};
            list['pid'] = pid;
            list['name'] = bundle;
            process.list.push(list);//Running bundles.
            process.pids[bundle] = pid;

            list = null;
        }
    };

    this.onReady = function(cb) {
        self.once('proc#complete', function(err){
            cb(err)
        })
    }

    //Init.
    if ( typeof(this.bundle) == "undefined" ) {
        console.error('Invalid or undefined proc name . Proc naming Aborted')
    } else {
        init()
    }
}
158526
function (path, callback) {
    fs.stat(path, function (err, stats) {
        failOn(err, "Error while reading the resolver path:", err);
        if (stats.isFile()) {
            TomahawkJS.loadAxe(path, _.partial(statResolver, callback));
        } else if (stats.isDirectory()) {
            // Load the resolver from a directory.
            TomahawkJS.loadDirectory(path, _.partial(startResolver, callback));
        } else {
            // Will be interesting what kind of fs type people will access here
            console.error("Unsupported FS item for a resolver bundle.");
            process.exit(1);
        }
    });
}
386650
function bundleHandler (pathToHandlers, module, file) {

    // only rebundle if js file changed
    if (file.length < 3 || file.indexOf('bundle.') === 0 || file.substr(file.length - 3) !== '.js') {
        return;
    }

    // only rebundle if handler was already bundled before
    fs.access(pathToHandlers + '/bundle.' + file, err => {

        if (err && err.code === 'ENOENT') {
            return ;
        }

        let fnIri = module + '/' + file.slice(0, -3);

        // remove the old bundle
        fs.unlink(pathToHandlers + '/bundle.' + file, err => {

            if (err) {
                console.log('Failed to delete old bundle for handler: ' + fnIri);
                return console.log(err);
            }

            // build the new bundle
            console.log('Bundle handler: ' + fnIri);
            runtime.bundle(fnIri, {}, (err) => {

                if (err) {
                    console.log('Failed to bundle handler: ' + fnIri);
                    return console.log(err);
                }

                console.log('Bundle done for handler: ' + fnIri);
            });
        });
    });
}
1070009
function Path( option ) {
        this._path = option.path;
        this._values = option.values;
        this._preset = option.preset;
        this._limit = option.limit;
        this._start = option.start;
        this._async = option.async;
        
        this._count = 0;        // count of finde node for ._start
        this._index = 0;        // Zeichenposition für regexp
        // this.level = option.level;        // console log
        // this.filter = option.filter;       // delete

        // this._success = option.success;
        // this._complete = option.complete;
    }
1167566
public void startBundle(Bundle bundle)
    {
        if (bundle != null)
            if ((bundle.getState() != Bundle.ACTIVE) && (bundle.getState() != Bundle.STARTING))
        {
            try {
                bundle.start();
            } catch (BundleException e) {
                e.printStackTrace();
            }
        }
    }
1062740
function compileFile( sourceBundle, bundleFile, config, callback ) {
	var fname = sourceBundle + "/bundle.json";
	fs.readFile(fname, 'utf8', function (err,data) {
		if (err) {
			console.error("Unable to load file",fname);
			if (callback) callback( err, null );
			return;
		}

		// Update path if missing
		if (!config['path'])
			config['path'] = path.dirname( sourceBundle );

		// Compile
		compile( JSON.parse(data), bundleFile, config, callback );

	});
}
892421
function objPath(obj, path) {
  if (!path) {
    return obj;
  }
  path = path.split('.');
  let i = 0;
  while (obj && i < path.length) {
    obj = obj[path[i++]];
  }
  return obj;
}
1296158
public static String get(Bundle bundle) {
    String applicationPath = ApplicationPath.get(bundle);
    if (applicationPath == null) {
      return null;
    }
    if (!hasHalDocs(bundle)) {
      return null;
    }
    return get(applicationPath);
  }
957630
function createDir(srcPath, desPath) {
    var pathInfo = path.parse(desPath);
    var searchvalue = pathInfo.root[pathInfo.root.length - 1]
    var start = 0;
    var found = pathInfo.dir.indexOf(searchvalue);
    var subPath = '';
    var dirs = [];

    if (found != -1) {
        while (true) {
            subPath = pathInfo.dir.substr(start, found - start + 1);
            if (subPath != '') {
                dirs.push(subPath);
            }
            start = found + 1;
            found = pathInfo.dir.indexOf(searchvalue, start);
            if (found == -1) {
                if (start < pathInfo.dir.length) {
                    dirs.push(pathInfo.dir.substr(start));
                }
                break;
            }
        }
    }

    subPath = '';
    dirs.forEach(function (dir, num) {
        subPath += dir;
        if (!fs.existsSync(subPath)) {
            try {
                fs.mkdirSync(subPath);
            } catch (e) {
                if (e.code != 'EEXIST') {
                    console.log('[error] ', e);
                };
            }
            console.log('[info] create  dir:', subPath);
        }
        if (num == dirs.length - 1 && pathInfo.base != '') {
            copyFile(srcPath, desPath);
            //console.log('src file:', srcPath);
            //console.log('des file:', desPath);
        }
    });

}
393158
def bundle_dir=(new_dir)
      if new_dir
        new_dir = Pathname.new(new_dir)
        new_dir.mkpath
      end
      @bundle_dir = new_dir
    end
145752
function paths(dir) {
	var paths = [];

	try {
		fs.statSync(dir);
	}
	catch (e) {
		return e;
	}

	(function traverse(dir, stack) {
		stack.push(dir);
		fs.readdirSync(stack.join('/')).forEach(function(file) {
			var path = stack.concat([file]).join('/'),
				stat = fs.statSync(path);

			if (file[0] == '.' || file === 'vendor') {
				return;
			} else if (stat.isFile() && /\.js$/.test(file)) {
				paths.push(path);
			} else if (stat.isDirectory()) {
				paths.push(path);
				traverse(file, stack);
			}
		});
		stack.pop();
	})(dir || '.', []);

	return paths;
}
1189302
function _checkPath (npmPath) {
  return new Promise((resolve, reject) => {
    if (npmPath) {
      fs.lstat(npmPath, (err, stats) => {
        if (err || !stats || (stats.isDirectory && !stats.isDirectory())) {
          reject(new Error(strings.givenPathNotValid(npmPath)))
        } else {
          resolve({
            path: npmPath,
            message: strings.givenPathValid(npmPath)
          })
        }
      })
    } else {
      reject(new Error('Called _checkPath() with insufficient parameters'))
    }
  })
}
1271538
function bundleJavascript() {
  const bundleEntryPath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.js');
  const bundlePath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.bundle.js');

  // Put together our "bundler", which uses browserify
  const browserifyOpts = {
    entries: [ bundleEntryPath ],
    standalone: 'hierplane'
  };

  // If we're watching or changes, enable watchify
  if (isWatchTarget) {
    // These are required for watchify
    browserifyOpts.packageCache = {};
    browserifyOpts.cache = {};

    // Enable the plugin
    browserifyOpts.plugin = [ watchify ];
  };

  // Construct the bundler
  const bundler = browserify(browserifyOpts);

  // Make an inline function which writes out the bundle, so that we can invoke it whenever
  // an update is detected if the watch target is being executed.
  const writeBundle = () => {
    console.log(chalk.cyan(`bundling ${chalk.magenta(path.relative(execArgs.cwd, bundleEntryPath))}`));
    bundler.bundle().pipe(fs.createWriteStream(bundlePath))
    console.log(chalk.green(`wrote ${chalk.magenta(path.relative(execArgs.cwd, bundlePath))}`));
  };

  // Write out the bundle once
  writeBundle();

  // If we're supposed to watch for changes, write out the bundle whenever they occur
  if (isWatchTarget) {
    bundler.on('update', writeBundle);
  }
}
669561
function resolvePath(_path, relativePath = currentWorkDir) {
  if (!isString(_path) || _path.startsWith('~')) {
    return _path;
  }
  const file = nativePath.relative(relativePath, _path);
  return nativePath.join(relativePath, file);
}
462421
function _resolve(from, to) {
	if (typeof to === 'undefined') {
		to = from;
		from = void(0);
	}

	if (!path.extname(to)) {
		to += '.js';
	}

	return (typeof from === 'undefined') ? path.resolve(to) : path.resolve(from, to);
}
765351
function createUnpackedBundle() {
  fs.mkdirp(unpackedDir, err => {
    if (err && err.code !== 'EEXIST') {
      console.log(err);
      throw err;
    }

    let unpackedFile = path.join(__dirname, 'unpacked.js');
    let b = browserify(unpackedFile).bundle();
    b.on('error', console.error);
    let unpackedBundleFile = path.join(unpackedDir, 'unpacked-bundle.js');
    const bundleFileStream = fs.createWriteStream(unpackedBundleFile);
    bundleFileStream.on('finish', () => {
      console.log('Wrote bundled JS into ' + unpackedBundleFile);
    });
    bundleFileStream.on('pipe', () => {
      console.log('Writing bundled JS...');
    });
    bundleFileStream.on('error', console.error);
    b.pipe(bundleFileStream);
    // bundleFileStream.end();  // do not do this prematurely!
  });
}
453805
function loadPaths (pkg) {
  const name = pkg.name
  const file = pkg.path
  return resolveFile(tmp, path.join(name, file)).then(entry => ({
    entry: entry,
    package: path.join(tmp, 'node_modules', name, 'package.json')
  }))
}