Skip to content

Commit

Permalink
add depends in options
Browse files Browse the repository at this point in the history
  • Loading branch information
Filirom1 committed Sep 18, 2012
1 parent 2c816bc commit 1856ec0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/createPkg.coffee
Expand Up @@ -22,7 +22,7 @@ module.exports = (npmName, makePkgArgv, options, cb) ->
tmpDir = '/tmp/npm2archinstall-' + randomId

# Create a package for archlinux with makepkg cmd
npm2arch npmName, (err, pkgbuild)->
npm2arch npmName, options, (err, pkgbuild)->
return cb err if err
# Create a tmp directory to work on
fs.mkdir tmpDir, '0755', (err)->
Expand Down
11 changes: 9 additions & 2 deletions lib/npm2PKGBUILD.coffee
Expand Up @@ -5,7 +5,13 @@ fs = require 'fs'

# transform pkg.json of `npmName` into a PKGBUILD
# `cb` is called like this: `cb(err, pkgbuild)`
module.exports = (npmName, cb) ->
module.exports = (npmName, options, cb) ->

if typeof options is 'function'
cb = options
options = null

options or= {}

# Execute npm info `argv[0]`
npm.load loglevel:'silent', (er)->
Expand All @@ -24,6 +30,7 @@ module.exports = (npmName, cb) ->
pkg.maintainers = [pkg.maintainers] if typeof pkg.maintainers is 'string'
pkg.homepage or= pkg.url
pkg.homepage or= pkg.repository.url.replace(/^git(@|:\/\/)/, 'http://').replace(/\.git$/, '').replace(/(\.\w*)\:/g, '$1\/') if pkg.repository?.url
pkg.depends = options.depends
populateTemplate pkg

# Populate the template
Expand All @@ -48,7 +55,7 @@ pkgdesc=\"{{{description}}}\"
arch=(any)
url=\"{{{homepage}}}\"
license=({{#licenses}}{{{type}}}{{/licenses}})
depends=(nodejs)
depends=('nodejs' {{#depends}}'{{{.}}}' {{/depends}})
source=(http://registry.npmjs.org/$_npmname/-/$_npmname-$pkgver.tgz)
noextract=($_npmname-$pkgver.tgz)
sha1sums=({{#dist}}{{{shasum}}}{{/dist}})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "Filirom1 <filirom1@gmail.com>",
"name": "npm2arch",
"description": "Convert NPM package to a PKGBUILD for ArchLinux",
"version": "0.1.10",
"version": "0.1.11",
"homepage": "https://github.com/Filirom1/npm2arch",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion test/npm2arch.coffee
Expand Up @@ -11,7 +11,7 @@ vows.describe('Test npm2arch')
.addBatch
'When calling npm2PKGBUILD with an existing package in npm':
topic: ->
npm2PKGBUILD 'npm2arch', @callback
npm2PKGBUILD 'npm2arch', depends: ['curl', 'git'], @callback
return
'Then a PKGBUILD is created': (err, pkgbuild) ->
assert.isNull err
Expand All @@ -21,6 +21,7 @@ vows.describe('Test npm2arch')
assert.include pkgbuild, "license=(MIT)"
assert.include pkgbuild, 'url="https://github.com/Filirom1/npm2arch"'
assert.include pkgbuild, 'pkgdesc="Convert NPM package to a PKGBUILD for ArchLinux"'
assert.include pkgbuild, "depends=('nodejs' 'curl' 'git' )"

'When calling npm2PKGBUILD with a packge in UPPER CASE':
topic: ->
Expand Down

0 comments on commit 1856ec0

Please sign in to comment.