1 // Copyright 2013 The Obvious Corporation.
4 * @fileoverview Helpers made available via require('phantomjs') once package is
9 var path = require('path')
13 * Where the phantom binary can be found.
17 var location = require('./location')
18 exports.path = path.resolve(__dirname, location.location)
19 exports.platform = location.platform
20 exports.arch = location.arch
22 // Must be running inside install script.
28 * The version of phantomjs installed by this package.
31 exports.version = '1.9.8'
35 * Returns a clean path that helps avoid `which` finding bin files installed
36 * by NPM for this repo.
37 * @param {string} path
40 exports.cleanPath = function (path) {
42 .replace(/:[^:]*node_modules[^:]*/g, '')
43 .replace(/(^|:)\.\/bin(\:|$)/g, ':')
49 // Make sure the binary is executable. For some reason doing this inside
50 // install does not work correctly, likely due to some NPM step.
53 // avoid touching the binary if it's already got the correct permissions
54 var st = fs.statSync(exports.path);
55 var mode = st.mode | parseInt("0555", 8);
56 if (mode !== st.mode) {
57 fs.chmodSync(exports.path, mode);
60 // Just ignore error if we don't have permission.
61 // We did our best. Likely because phantomjs was already installed.