Skip to content

Commit

Permalink
Using require-relative to resolve modules for transforms in the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
arian committed Dec 27, 2013
1 parent 915b6fb commit b3b594f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ wrup amd-combined --require ./main.js
# piping the AST JSON into uglifyjs
wrup browser --require ./main.js --ast | uglifyjs --spidermonkey -c -m

# use transforms, for example to compile coffeescript
wrup browser -r ./test.coffee --transform coffeeify

# source maps
wrup browser -r ./main.js --output test.js --source-map test.map

Expand Down
17 changes: 9 additions & 8 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";

var path = require('path')
var program = require('commander')
var chalk = require('chalk')
var WrapUp = require('../lib/wrapup')
var json = require('../package')
var error = require('./errorHandler')
var path = require('path')
var program = require('commander')
var chalk = require('chalk')
var relative = require('require-relative').resolve
var WrapUp = require('../lib/wrapup')
var json = require('../package')
var error = require('./errorHandler')

var wrapup = new WrapUp()

Expand All @@ -22,6 +23,7 @@ program
.option('-r, --require <path>', 'requires a module. Uses node to resolve modules. If the form namepace=path is used the module will use a namespace')
.option('-t, --transform <module>', 'requires a module for transforming source code of modules')
.option('-w, --watch', 'watch changes to every resolved module and wraps up')
.option('-t, --transform', 'a module that can transform source code or ASTs')
.option('--in-path <path>', 'all required files should be in this path')

program.on('require', function(option){
Expand All @@ -31,8 +33,7 @@ program.on('require', function(option){
})

program.on('transform', function(option){
if (option.charAt(0) == '.') option = process.cwd() + '/' + option
wrapup.scanner.addTransform(require(option))
wrapup.scanner.addTransform(require(relative(option)))
})

program.on('in-path', function(option){
Expand Down

0 comments on commit b3b594f

Please sign in to comment.