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

Custom binary name name #1

Merged
merged 3 commits into from Jul 11, 2012
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
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
node_modules/
*.swo
*.swp
14 changes: 8 additions & 6 deletions phantom.coffee
Expand Up @@ -3,8 +3,8 @@ express = require 'express'
child = require 'child_process'

phanta = []
startPhantomProcess = (port, args) ->
ps = child.spawn 'phantomjs', args.concat [__dirname+'/shim.js', port]
startPhantomProcess = (port, args, binaryPath) ->
ps = child.spawn binaryPath, args.concat [__dirname+'/shim.js', port]

ps.stdout.on 'data', (data) -> console.log "phantom stdout: #{data}"
ps.stderr.on 'data', (data) ->
Expand All @@ -27,18 +27,19 @@ wrap = (ph) ->



module.exports =
create: (args..., cb) ->
module.exports =
create: (args..., cb, binaryPath) ->
app = express.createServer()
app.use express.static __dirname

appServer = app.listen()

server = dnode()

phantom = null

ps = startPhantomProcess appServer.address().port, args
binaryPath = binaryPath || 'phantomjs'

ps = startPhantomProcess appServer.address().port, args, binaryPath

ps.on 'exit', (code) ->
appServer.close()
Expand All @@ -52,6 +53,7 @@ module.exports =
phantom = conn.remote
wrap phantom
phanta.push phantom
phantom.__binaryPath = binaryPath
cb? phantom


Expand Down
25 changes: 16 additions & 9 deletions phantom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.