Registers all of the eligible files from the commands
directory as commands with the bot.

@param {string} basedir - The base directory which holds the commands directory
@param {object} bot - An instance of DubBotBase.Bot
556338
function _registerCommands(basedir, globalObject) {
    var commandsDir = path.resolve(basedir, "commands");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(commandsDir);
        LOG.info("Found the following potential command files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register commands from the base directory '{}'. Error: {}", commandsDir, e);
        return;
    }

    var commands = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        if (!module.triggers || !module.handler) {
            LOG.warn("Found a module at {} but it doesn't appear to be a command handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            module.init(globalObject);
        }

        commands.push(module);
        LOG.info("Registered command from file {}", filePath);
    }

    return commands;
}
1122554
public static void bundle(File basedir, File output, Reporter reporter) throws IOException {
        ProjectScanner scanner = new ProjectScanner(basedir);

        // Loads the properties inherited from Maven.
        Properties instructions = readMavenProperties(basedir);
        // Loads the properties from the BND file.
        Properties fromBnd = readInstructionsFromBndFile(basedir);
        if (fromBnd == null) {
            // No bnd files, use default instructions
            instructions = populatePropertiesWithDefaults(basedir, instructions, scanner);
        } else {
            // We have a BND file.
            // Do we have to merge ?
            String noDefaultValue = fromBnd.getProperty("-no-default");
            if (!"true".equalsIgnoreCase(noDefaultValue)) {
                // So we need to merge the default with the bnd files
                // 1) merge the instructions from the bnd files with the default
                // 2) merge the resulting set of instruction onto the maven properties
                // (and override the default)
                instructions = Instructions.mergeAndOverrideExisting(
                        instructions,
                        populatePropertiesWithDefaults(basedir, fromBnd, scanner));
            } else {
                instructions = Instructions.mergeAndOverrideExisting(instructions, fromBnd);
            }
        }

        // Manage Embedded dependencies
        DependencyEmbedder ed = new DependencyEmbedder(instructions, reporter);
        instructions = ed.generate(instructions, org.wisdom.maven.osgi.Classpath.load(basedir));

        // Integrate custom headers added by other plugins.
        instructions = mergeExtraHeaders(basedir, instructions);

        // For debugging purpose, dump the instructions to target/osgi/instructions.properties
        FileOutputStream fos = null;
        try {
            File out = new File(basedir, "target/osgi/instructions.properties");
            fos = new FileOutputStream(out);
            instructions.store(fos, "Wisdom BND Instructions");
        } catch (IOException e) { // NOSONAR
            // Ignore it.
        } finally {
            IOUtils.closeQuietly(fos);
        }

        // Instructions loaded, start the build sequence.
        final Jar[] jars = org.wisdom.maven.osgi.Classpath.computeClassPath(basedir);

        File bnd;
        File ipojo;
        Builder builder = null;
        try {
            builder = getOSGiBuilder(basedir, instructions, jars);
            // The next sequence is weird
            // First build the bundle with the given instruction
            // Then analyze to apply the plugin and fix
            // finally, rebuild with the updated metadata
            // Without the first build, embedded dependencies and private packages from classpath are not analyzed.
            builder.build();
            builder.analyze();
            builder.build();

            reportErrors(builder.getWarnings(), builder.getErrors(), reporter);
            bnd = File.createTempFile("bnd-", ".jar");
            ipojo = File.createTempFile("ipojo-", ".jar");
            builder.getJar().write(bnd);
        } catch (Exception e) {
            throw new IOException("Cannot build the OSGi bundle", e);
        }  finally {
            if (builder != null) {
                builder.close();
            }
        }

        final Set<String> elements = org.wisdom.maven.osgi.Classpath.computeClassPathElement(basedir);
        Classpath classpath = new Classpath(elements);
        Pojoization pojoization = new Pojoization();
        pojoization.pojoization(bnd, ipojo, new File(basedir, "src/main/resources"),
                classpath.createClassLoader());
        reportErrors(pojoization.getWarnings(), pojoization.getErrors(), reporter);

        Files.move(Paths.get(ipojo.getPath()), Paths.get(output.getPath()),
                StandardCopyOption.REPLACE_EXISTING);
    }
803449
public function recursivelyDeleteFromDirectory($baseDirectory)
    {
        if (!is_dir($baseDirectory)) {
            return;
        }

        $iterator = new \RecursiveDirectoryIterator($baseDirectory);
        $files = new \RecursiveIteratorIterator(
            $iterator,
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $file) {
            $fname = $file->getFilename();
            if ($fname == '.' || $fname == '..') {
                continue;
            }

            if ($file->isDir()) {
                $this->recursivelyDeleteFromDirectory($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }

        rmdir($baseDirectory);

        return;
    }
819210
private function process($srcFiles, $basedir)
    {
        // Log
        $this->log("Processing files with base directory ($basedir) ", $this->loglevel);
        $targets = [];
        if ($this->targetFilePos !== null) {
            $addedFiles = [];
            foreach ($srcFiles as $count => $file) {
                if ($this->mapper !== null) {
                    $subTargets = $this->mapper->main($file);
                    if ($subTargets !== null) {
                        foreach ($subTargets as $subTarget) {
                            if ($this->relative) {
                                $name = $subTarget;
                            } else {
                                $name = (new PhingFile($this->destDir, $subTarget))->getAbsolutePath();
                            }
                            if ($this->forwardslash && PhingFile::$separator !== '/') {
                                $name = str_replace(PhingFile::$separator, '/', $name);
                            }
                            if (!isset($addedFiles[$name])) {
                                $targets[] = $name;
                                $addedFiles[] = $name;
                            }
                        }
                    }
                }
            }
        }
        $targetFiles = $targets;

        if (!$this->addsourcefile) {
            $srcFiles = [];
        }
        $orig = $this->commandline->getCommandline();
        $result = []; // range(0,count($orig) + count($srcFiles) + count($targetFiles));

        $srcIndex = count($orig);
        if ($this->srcFilePos !== null) {
            $srcIndex = $this->srcFilePos->getPosition();
        }
        if ($this->targetFilePos !== null) {
            $targetIndex = $this->targetFilePos->getPosition();

            if ($srcIndex < $targetIndex || ($srcIndex === $targetIndex && $this->srcIsFirst)) {
                // 0 --> srcIndex
                $result[] = $orig;

                // srcIndex --> targetIndex
                $result += array_slice($orig, $srcIndex + count($srcFiles), $targetIndex - $srcIndex, true);

                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $targetIndex,
                        true
                    ),
                    $result
                );
            } else {
                // 0 --> targetIndex
                $result[] = $orig;
                $result[] = $targetFiles;
                $result = array_merge(... $result);

                // targetIndex --> srcIndex
                $result = array_merge(
                    array_slice(
                        $orig,
                        $targetIndex + count($targetFiles),
                        $srcIndex - $targetIndex,
                        true
                    ),
                    $result
                );

                // srcIndex --> end
                $result = array_merge(
                    array_slice(
                        $orig,
                        $srcIndex + count($srcFiles) + count($targetFiles),
                        count($orig) - $srcIndex,
                        true
                    ),
                    $result
                );
                $srcIndex += count($targetFiles);
            }
        } else { // no targetFilePos

            // 0 --> srcIndex
            $result = array_merge(array_slice($orig, 0, $srcIndex, true), $result);
            // srcIndex --> end
            $result = array_merge(
                array_slice($orig, $srcIndex + count($srcFiles), count($orig) - $srcIndex, true),
                $result
            );
        }
        // fill in source file names
        foreach ($srcFiles as $i => $file) {
            if ($this->relative) {
                $src = $file;
            } else {
                $src = (new PhingFile($basedir, $file))->getAbsolutePath();
            }
            if ($this->forwardslash && PhingFile::$separator !== '/') {
                $src = str_replace(PhingFile::$separator, '/', $src);
            }
            if ($this->srcFilePos !== null && ($this->srcFilePos->getPrefix() !== ''
                    || $this->srcFilePos->getSuffix() !== '')
            ) {
                $src = $this->srcFilePos->getPrefix() . $src . $this->srcFilePos->getSuffix();
            }
            $result[$srcIndex + $i] = $src;
        }

        $this->commandline = new Commandline(implode(' ', $result));
        $this->commandline->setEscape($this->escape);
        $this->realCommand = (string) $this->commandline . $this->additionalCmds;

        [$returncode, $output] = $this->executeCommand();

        $this->maybeSetReturnPropertyValue($returncode);

        // Sets the output property
        if ($this->outputProperty) {
            $previousValue = $this->project->getProperty($this->outputProperty);
            if (!empty($previousValue)) {
                $previousValue .= "\n";
            }
            $this->project->setProperty($this->outputProperty, $previousValue . implode("\n", $output));
        }

        // Validating the 'return-code'
        if ($this->checkreturn && ($returncode !== 0)) {
            $this->throwBuildException("Task exited with code ($returncode)");
        }
    }
53631
def _create_paths(self, basedir, name=None):
        """"""
        if name:
            datapath = os.path.join(basedir, name)
        else:
            datapath = basedir

        dbpath = os.path.join(datapath, 'db')
        if not os.path.exists(dbpath):
            os.makedirs(dbpath)
        if self.args['verbose']:
            print('creating directory: %s' % dbpath)

        return datapath
877035
public static function init($baseDir = "", $verbose = true) {
		
		// make sure a base dir was supplied
		if (empty($baseDir)) {
			Console::writeError("need a base directory to initialize the config class...");
		}
		
		// normalize the baseDir
		$baseDir = FileUtil::normalizePath($baseDir);
		
		// double-check the default config file exists
		if (!is_dir($baseDir)) {
			Console::writeError("make sure ".$baseDir." exists...");
		}
		
		// set the baseDir option
		self::$options["baseDir"] = ($baseDir[strlen($baseDir)-1] == DIRECTORY_SEPARATOR) ? $baseDir : $baseDir.DIRECTORY_SEPARATOR;
		
		// set-up the paths
		self::$userConfigDirClean  = self::$options["baseDir"].self::$userConfigDirClean;
		self::$userConfigDirDash   = self::$options["baseDir"].self::$userConfigDirDash;
		self::$userConfigDir       = (is_dir(self::$userConfigDirDash)) ? self::$userConfigDirDash : self::$userConfigDirClean;
		self::$userConfigPath      = self::$userConfigDir.DIRECTORY_SEPARATOR.self::$userConfig;
		self::$plConfigPath        = self::$options["baseDir"]."vendor/pattern-lab/core/".self::$plConfigPath;
		
		// can't add __DIR__ above so adding here
		if (!is_dir(self::$userConfigDir)) {
			mkdir(self::$userConfigDir);
		}
		
		// check to see if the user config exists, if not create it
		if ($verbose) {
			Console::writeLine("configuring pattern lab...");
		}
		
		// make sure migrate doesn't happen by default
		$migrate        = false;
		$diffVersion    = false;
		$defaultOptions = array();
		$userOptions    = array();
		
		// double-check the default config file exists
		if (!file_exists(self::$plConfigPath)) {
			Console::writeError("the default options for Pattern Lab don't seem to exist at <path>".Console::getHumanReadablePath(self::$plConfigPath)."</path>. please check on the install location of pattern lab...");
		}
		
		// set the default config using the pattern lab config
		try {
			$defaultOptions = Yaml::parse(file_get_contents(self::$plConfigPath));
			self::$options  = array_merge(self::$options, $defaultOptions);
		} catch (ParseException $e) {
			Console::writeError("Config parse error in <path>".Console::getHumanReadablePath(self::$plConfigPath)."</path>: ".$e->getMessage());
		}
		
		// double-check the user's config exists. if not mark that we should migrate the default one
		if (file_exists(self::$userConfigPath)) {
			try {
				$userOptions   = Yaml::parse(file_get_contents(self::$userConfigPath));
				self::$options = array_merge(self::$options, $userOptions);
			} catch (ParseException $e) {
				Console::writeError("Config parse error in <path>".Console::getHumanReadablePath(self::$userConfigPath)."</path>: ".$e->getMessage());
			}
		} else {
			$migrate = true;
		}
		
		// compare version numbers
		$diffVersion = (isset($userOptions["v"]) && ($userOptions["v"] == $defaultOptions["v"])) ? false : true;
		
		// run an upgrade and migrations if necessary
		if ($migrate || $diffVersion) {
			if ($verbose) {
				Console::writeInfo("upgrading your version of pattern lab...");
			}
			if ($migrate) {
				if (!@copy(self::$plConfigPath, self::$userConfigPath)) {
					Console::writeError("make sure that Pattern Lab can write a new config to ".self::$userConfigPath."...");
					exit;
				}
			} else {
				self::$options = self::writeNewConfigFile(self::$options, $defaultOptions);
			}
		}
		
		// making sure the config isn't empty
		if (empty(self::$options) && $verbose) {
			Console::writeError("a set of configuration options is required to use Pattern Lab...");
			exit;
		}
		
		// set-up the various dirs
		self::$options["configDir"]        = self::$userConfigDir;
		self::$options["configPath"]       = self::$userConfigPath;
		self::$options["coreDir"]          = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core";
		self::$options["exportDir"]        = isset(self::$options["exportDir"])        ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"])   : self::$options["baseDir"]."exports";
		self::$options["publicDir"]        = isset(self::$options["publicDir"])        ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"])   : self::$options["baseDir"]."public";
		self::$options["scriptsDir"]       = isset(self::$options["scriptsDir"])       ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"])  : self::$options["baseDir"]."scripts";
		self::$options["sourceDir"]        = isset(self::$options["sourceDir"])        ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"])   : self::$options["baseDir"]."source";
		self::$options["componentDir"]     = isset(self::$options["componentDir"])     ? self::$options["publicDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["componentDir"]) : self::$options["publicDir"].DIRECTORY_SEPARATOR."patternlab-components";
		self::$options["dataDir"]          = isset(self::$options["dataDir"])          ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["dataDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_data";
		self::$options["patternExportDir"] = isset(self::$options["patternExportDir"]) ? self::$options["exportDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternExportDir"]) : self::$options["exportDir"].DIRECTORY_SEPARATOR."patterns";
		self::$options["patternPublicDir"] = isset(self::$options["patternPublicDir"]) ? self::$options["publicDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternPublicDir"]) : self::$options["publicDir"].DIRECTORY_SEPARATOR."patterns";
		self::$options["patternSourceDir"] = isset(self::$options["patternSourceDir"]) ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["patternSourceDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_patterns";
		self::$options["metaDir"]          = isset(self::$options["metaDir"])          ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["metaDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_meta/";
		self::$options["annotationsDir"]   = isset(self::$options["annotationsDir"])   ? self::$options["sourceDir"].DIRECTORY_SEPARATOR.self::cleanDir(self::$options["annotationsDir"]) : self::$options["sourceDir"].DIRECTORY_SEPARATOR."_annotations/";
		
		// set-up outputFileSuffixes
		self::$options["outputFileSuffixes"]["rendered"]    = isset(self::$options["outputFileSuffixes"]["rendered"])    ? self::$options["outputFileSuffixes"]["rendered"]    : '';
		self::$options["outputFileSuffixes"]["rawTemplate"] = isset(self::$options["outputFileSuffixes"]["rawTemplate"]) ? self::$options["outputFileSuffixes"]["rawTemplate"] : '';
		self::$options["outputFileSuffixes"]["markupOnly"]  = isset(self::$options["outputFileSuffixes"]["markupOnly"])  ? self::$options["outputFileSuffixes"]["markupOnly"]  : '.markup-only';
		
		// handle a pre-2.1.0 styleguideKitPath before saving it
		if (isset(self::$options["styleguideKitPath"])) {
			self::$options["styleguideKitPath"] = self::$options["baseDir"].self::cleanDir(self::getStyleguideKitPath(self::$options["styleguideKitPath"]));
		}
		
		// double-check a few directories are real and set-up
		FileUtil::checkPathFromConfig(self::$options["sourceDir"], self::$userConfigPath, "sourceDir");
		FileUtil::checkPathFromConfig(self::$options["publicDir"], self::$userConfigPath, "publicDir");
		
		// make sure styleguideExcludes is set to an array even if it's empty
		if (is_string(self::$options["styleGuideExcludes"])) {
			self::$options["styleGuideExcludes"] = array();
		}
		
		// set the cacheBuster
		self::$options["cacheBuster"] = (self::$options["cacheBusterOn"] == "false") ? 0 : time();
		
		// provide the default for enable CSS. performance hog so it should be run infrequently
		self::$options["enableCSS"] = false;
		
		// which of these should be exposed in the front-end?
		self::$options["exposedOptions"] = array();
		self::setExposedOption("cacheBuster");
		self::setExposedOption("defaultPattern");
		self::setExposedOption("defaultShowPatternInfo");
		self::setExposedOption("patternExtension");
		self::setExposedOption("ishFontSize");
		self::setExposedOption("ishMaximum");
		self::setExposedOption("ishMinimum");
		self::setExposedOption("ishViewportRange");
		self::setExposedOption("outputFileSuffixes");
		self::setExposedOption("patternStates");
		self::setExposedOption("theme");
		self::setExposedOption("plugins");
		
	}
228649
function(callback) {

            var binary = binaries.bower;
            binary.command = 'bower --allow-root install';

            helper.runCommand(
                binary, path,
                'bower binary is not ready to use, fix this (npm install -g bower)  and retry ' +
                'installation of frontend dependencies manually'.grey,
                callback
            );
        }
429665
def scan_directory_for_bot_configs(root_dir) -> Set[BotConfigBundle]:
    

    configs = set()

    for filename in glob.iglob(os.path.join(root_dir, '**/*.cfg'), recursive=True):
        try:
            bundle = get_bot_config_bundle(filename)
            configs.add(bundle)
        except (NoSectionError, MissingSectionHeaderError, NoOptionError, AttributeError, ParsingError, FileNotFoundError):
            pass

    return configs
1139566
function registerTask( task ) {
		grunt.registerMultiTask( task.name, task.help, function () {
			var done = this.async();
			if ( ensureSketchtool() ) {
				var options = this.options();

				var commands = [];
				this.files.forEach( function( file ) {
					file.src.filter( function ( src ) {
						var command = createCommand( task, src, file.dest, options );
						if ( command ) {
							commands.push( command );
						}
					} );
				});
				
				async.eachLimit( commands, numCPUs, function ( command, next ) {
					executeCommand( command, next );
				}, done );
			} else {
				done(false);
			}
		} );
	}
8243
private function scanModuleFolders($basedir, &$folders)
    {
        if (is_dir($basedir) && ($h = opendir($basedir))) {
            while (($folder = readdir($h))) {
                if ($folder !== '.' && $folder !== '..') {
                    $this->scanModuleFiles($basedir . DIRECTORY_SEPARATOR . $folder, $folders);
                }
            }
            closedir($h);
        }
    }
650373
def bots_create(self, bot):
        
        self.client.bots(_method="POST", _json=bot.to_json(), _params=dict(userToken=self.token))
565001
def _normalize_basedir(basedir=None):
    '''
    
    '''
    # if we are passed a string (for backward compatibility), convert to a list
    if isinstance(basedir, six.string_types):
        basedir = [x.strip() for x in basedir.split(',')]

    if basedir is None:
        basedir = []

    # nothing specified, so use the reposdir option as the default
    if not basedir:
        basedir = _get_yum_config_value('reposdir')

    if not isinstance(basedir, list) or not basedir:
        raise SaltInvocationError('Could not determine any repo directories')

    return basedir
1145628
function add (cb) {
    var files = my.args
    // Check for file arguements
    if (files.length === 0) {
      return cb( erf ('<add> command requires file arguements', usage))
    }
    // Get bin and run chained processes
    async.asyncMap( files, processchain , function (err) {
      if (err) return cb(err)  //ERRORS FROM PROCESSING CHAIN
      cb(null,my.state)
    })  // end asyncMap

    function processchain (file, cb_) {
      var source = path.join(process.cwd(),file)
      , targetdir = getActiveBin(my.state.bins)
      async.chain( [checkState, source, false]
                   , [copyFile, source, targetdir]
                   , [changeState, source, 'add']
                   , cb_ )
    }  //end processchain
  }
1093553
function createBot() {
  var bot = function(platform, context, event, next) {
    context.platform = platform;
    bot.handle(context, event, next);
  };

  mixin(bot, EventEmitter.prototype, false);
  mixin(bot, proto, false);

  bot.context = { __proto__: context, bot: bot };
  bot.event = { __proto__: event, bot: bot };
  bot.display_name = "bot"; // default, should be overwritten
  bot.init();
  return bot;
}
580046
function _registerEventListeners(basedir, globalObject) {
    var bot = globalObject.bot;
    var eventListenerDir = path.resolve(basedir, "event_listeners");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(eventListenerDir);
        LOG.info("Found the following potential event listener files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register event listeners from the base directory '{}'. Error: {}", eventListenerDir, e);
        return;
    }

    var listeners = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        /* Check each event key and look for an export in one of two forms:
         *
         * 1) EVENT_KEY : some_function
         * 2) EVENT_KEY : { handler: some_function, context: some_object }
         *
         * Context is optional even in the second form, but a function is always required.
         */
        var eventHandlerFound = false;
        for (var eventKey in Event) {
            var eventValue = Event[eventKey];
            var eventHandler = null;
            var handlerContext = null;
            var error = null;

            if (!module[eventValue]) {
                continue;
            }

            if (typeof module[eventValue] === "function") {
                eventHandler = module[eventValue];
            }
            else if (typeof module[eventValue] === "object") {
                if (typeof module[eventValue].handler !== "function") {
                    LOG.error("An error occurred while reading event listener from file {}", filePath);
                    LOG.error("Event listener for event '{}' has an object type, but the 'handler' property does not refer to a function", eventKey);
                    throw new Error("An error occurred while initializing event listeners. Check your logfile (or just stdout) for more details.");
                }

                eventHandler = module[eventValue].handler;
                handlerContext = module[eventValue].context;
            }
            else {
                LOG.warn("Found what looks like an event listener, but it's not an object or a function. Event: {}, from file: {}", eventKey, filePath);
                continue;
            }

            eventHandlerFound = true;
            bot.on(eventValue, eventHandler, handlerContext);
        }

        if (!eventHandlerFound) {
            LOG.warn("Found a module at {} but it doesn't appear to be an event handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            LOG.info("Calling init for module at {}", filePath);
            module.init(globalObject);
        }

        listeners.push(module);
        LOG.info("Registered event listener from file {}", filePath);
    }

    return listeners;
}
508416
function _loadCommandsFromDir(dirPath, disabled, callback) {
    var commands = {};
    fs.readdir(dirPath, function(err, fileNames) {
        if (err) {
            return callback(err);
        }

        // Load each JS file as a command into the session
        _.chain(fileNames)

            // Only accept JS files
            .filter(function(fileName) {
                return (fileName.split('.').pop() === 'js');
            })

            // Pluck out the extension of the file name to get the command name
            .map(function(fileName) {
                return fileName.split('.').slice(0, -1).join('.');
            })

            // Don't accept any from the disabled list of command names
            .difference(disabled)

            // Add each command to the session
            .each(function(commandName) {
                commands[commandName] = require(path.join(dirPath, commandName));
            });

        return callback(null, commands);
    });
}
724318
public function registerCommands() : void {
		// Register a command for basset
		$this->app->singleton('command.basset', function($app) {
			return new BuildCommand($app['basset'], $app['basset.builder'], $app['basset.builder.cleaner']);
		});

		$this->commands('command.basset');
	}