Skip to content

Commit

Permalink
allows overriding fetcher repo recipes
Browse files Browse the repository at this point in the history
- addresses #374 with a simple config override
- this allows users to override the fetch repository from their
config/application.{js,coffee} like so:

```
fetcher: {
   recipeRepo: "https://github.com/davemo/fetcher-recipes"
}
```
  • Loading branch information
davemo committed Sep 11, 2015
1 parent 70417a2 commit 0875f13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions lib/cli/lineman-fetch.coffee
@@ -1,19 +1,18 @@
grunt = require('./../requires-grunt').require()
fetcher = require('fetcher')

module.exports = (recipes = [], cb) ->
return displayHelp() if recipes.length == 0
fetcher recipes, {recipeRepo: "https://github.com/linemanjs/fetcher-recipes.git"}, (er) ->
module.exports = (recipes = [], recipeRepo = "https://github.com/linemanjs/fetcher-recipes", cb) ->
return displayHelp(recipeRepo) if recipes.length == 0
fetcher recipes, {recipeRepo}, (er) ->
grunt.warn(er) if er?
return cb?(er) if er?
cb?(null)

displayHelp = ->
displayHelp = (recipeRepo) ->
grunt.warn """
Usage: `lineman fetch <recipe_name>`
For a list of available recipes, see:
https://github.com/linemanjs/fetcher-recipes/tree/master/recipes
#{recipeRepo}/tree/master/recipes
"""
9 changes: 6 additions & 3 deletions lib/cli/main.coffee
Expand Up @@ -7,6 +7,7 @@ packageJson = require("./../../package")
RunsNextCommand = require("./runs-next-command")
ReadsConfiguration = require("./../reads-configuration")
prettyPrintsValue = require("./../pretty-prints-value")
buildsAppConfig = require('./../builds-app-config')

_ = require("lodash")

Expand Down Expand Up @@ -88,9 +89,11 @@ module.exports = ->
description("Fetch a library and add it to your Lineman project").
action ->
recipes = _(@args).filter(_.isString)
require('./lineman-fetch')(recipes)


recipeRepo = buildsAppConfig.withUserOverrides().application.fetcher?.recipeRepo
if recipeRepo
require('./lineman-fetch')(recipes, recipeRepo)
else
require('./lineman-fetch')(recipes)

process.argv[2] = "help" if noCommandWasGiven()

Expand Down
1 change: 1 addition & 0 deletions lib/cli/setup-options.coffee
Expand Up @@ -6,6 +6,7 @@ module.exports = (commander, gruntCli) ->
commander.option("--skip-clean", "lineman build - Builds into the 'dist' directory without emptying it first.")
commander.option("--process", "lineman config - Process the grunt options, interpolating <%= %> template variables")
commander.option("--coffee", "lineman new - Create default files in CoffeeScript instead of JavaScript.")

_(gruntCli.optlist).each (option, name) ->
unless name in ["help", "version"]
desc = if option.negate then "--no-#{name}" else "--#{name}"
Expand Down

0 comments on commit 0875f13

Please sign in to comment.