Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes horrible bug that traversed the whole filesystem. #71

Merged
merged 1 commit into from Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gluegun/src/cli/index.js
Expand Up @@ -8,7 +8,7 @@ const loadPluginFromDirectory = require('../loaders/toml-plugin-loader')
const getPluginsFromConfig = require('../loaders/plugins-from-config')
const homePluginDirectories = require('../loaders/home-plugin-directories')
const toml = require('toml')
const printBanner = require('./print-banner')
// const printBanner = require('./print-banner')
const printCommands = require('./print-commands')
const printWtf = require('./print-wtf')
const printBrandHeader = require('./print-brand-header')
Expand Down
31 changes: 20 additions & 11 deletions packages/gluegun/src/loaders/toml-plugin-loader.js
Expand Up @@ -25,8 +25,8 @@ function loadFromDirectory (directory, options = {}) {
const plugin = new Plugin()

const key = options.key || 'gluegun'
const commandFilePattern = options.commandFilePattern || 'commands/*.js'
const extensionFilePattern = options.extensionFilePattern || 'extensions/*.js'
const commandFilePattern = options.commandFilePattern || '*.js'
const extensionFilePattern = options.extensionFilePattern || '*.js'
const namespace = options.namespace
if (!isBlank(namespace)) {
plugin.namespace = namespace
Expand All @@ -53,18 +53,27 @@ function loadFromDirectory (directory, options = {}) {
plugin.namespace = jetpack.inspect(directory).name
}

// load the commands found in the commands sub-directory
plugin.commands = map(
file => loadCommandFromFile(`${directory}/${file}`),
jetpack.cwd(plugin.directory).find({ matching: commandFilePattern })
)
const jetpackPlugin = jetpack.cwd(plugin.directory)

// load the commands found in the commands sub-directory
plugin.extensions = map(
file => loadExtensionFromFile(`${directory}/${file}`),
jetpack.cwd(plugin.directory).find({ matching: extensionFilePattern })
)
if (jetpackPlugin.exists('commands') === 'dir') {
plugin.commands = map(
file => loadCommandFromFile(`${directory}/commands/${file}`),
jetpackPlugin.cwd('commands').find({ matching: commandFilePattern, recursive: false })
)
} else {
plugin.commands = []
}

// load the commands found in the commands sub-directory
if (jetpackPlugin.exists('extensions') === 'dir') {
plugin.extensions = map(
file => loadExtensionFromFile(`${directory}/extensions/${file}`),
jetpackPlugin.cwd('extensions').find({ matching: extensionFilePattern, recursive: false })
)
} else {
plugin.extensions = []
}
// if we have a config toml
try {
// attempt to load the toml file
Expand Down