Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
Revert "Merge pull request #277 from corbinu/master"
Browse files Browse the repository at this point in the history
This reverts commit f3dcca8, reversing
changes made to d3b860c.
  • Loading branch information
Nick Santos committed Jan 27, 2015
1 parent c97d579 commit 8a96d60
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 18 additions & 5 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ var requestProgress = require('request-progress')
var progress = require('progress')
var AdmZip = require('adm-zip')
var cp = require('child_process')
var fs = require('fs-extra')
var fs = require('fs')
var helper = require('./lib/phantomjs')
var kew = require('kew')
var mkdirp = require('mkdirp')
var ncp = require('ncp')
var npmconf = require('npmconf')
var path = require('path')
var request = require('request')
var rimraf = require('rimraf')
var url = require('url')
var util = require('util')
var which = require('which')
Expand Down Expand Up @@ -181,7 +184,7 @@ function findSuitableTempDirectory(npmConf) {
var candidatePath = path.join(candidateTmpDirs[i], 'phantomjs')

try {
fs.mkdirsSync(candidatePath, '0777')
mkdirp.sync(candidatePath, '0777')
// Make double sure we have 0777 permissions; some operating systems
// default umask does not allow write by default.
fs.chmodSync(candidatePath, '0777')
Expand Down Expand Up @@ -297,7 +300,7 @@ function extractDownload(filePath) {
var extractedPath = filePath + '-extract-' + Date.now()
var options = {cwd: extractedPath}

fs.mkdirsSync(extractedPath, '0777')
mkdirp.sync(extractedPath, '0777')
// Make double sure we have 0777 permissions; some operating systems
// default umask does not allow write by default.
fs.chmodSync(extractedPath, '0777')
Expand Down Expand Up @@ -331,18 +334,28 @@ function extractDownload(filePath) {

function copyIntoPlace(extractedPath, targetPath) {
console.log('Removing', targetPath)
return kew.nfcall(fs.remove, targetPath).then(function () {
return kew.nfcall(rimraf, targetPath).then(function () {
// Look for the extracted directory, so we can rename it.
var files = fs.readdirSync(extractedPath)
for (var i = 0; i < files.length; i++) {
var file = path.join(extractedPath, files[i])
if (fs.statSync(file).isDirectory() && file.indexOf(helper.version) != -1) {
console.log('Copying extracted folder', file, '->', targetPath)
return kew.nfcall(fs.move, file, targetPath)
return kew.nfcall(ncp, file, targetPath)
}
}

console.log('Could not find extracted file', files)
throw new Error('Could not find extracted file')
})
.then(function () {
// Cleanup extracted directory after it's been copied
console.log('Removing', extractedPath)
return kew.nfcall(rimraf, extractedPath).fail(function (e) {
// Swallow the error quietly.
console.warn(e)
console.warn('Unable to remove temporary files at "' + extractedPath +
'", see https://github.com/Obvious/phantomjs/issues/108 for details.')
})
})
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
},
"dependencies": {
"adm-zip": "0.4.4",
"fs-extra": "^0.15.0",
"kew": "0.4.0",
"ncp": "~1.0.1",
"npmconf": "2.0.9",
"mkdirp": "0.5.0",
"progress": "1.1.8",
"request": "2.42.0",
"request-progress": "0.3.1",
"rimraf": "~2.2.8",
"which": "~1.0.5"
},
"devDependencies": {
Expand Down

0 comments on commit 8a96d60

Please sign in to comment.