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

Commit

Permalink
Merge pull request #282 from Medium/nick-rollback
Browse files Browse the repository at this point in the history
replace ncp/rimraf with fs-extra
  • Loading branch information
nicks committed Jan 28, 2015
2 parents 4bc8fb3 + 657470c commit 1bc7553
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
23 changes: 5 additions & 18 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ var requestProgress = require('request-progress')
var progress = require('progress')
var AdmZip = require('adm-zip')
var cp = require('child_process')
var fs = require('fs')
var fs = require('fs-extra')
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 @@ -184,7 +181,7 @@ function findSuitableTempDirectory(npmConf) {
var candidatePath = path.join(candidateTmpDirs[i], 'phantomjs')

try {
mkdirp.sync(candidatePath, '0777')
fs.mkdirsSync(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 @@ -300,7 +297,7 @@ function extractDownload(filePath) {
var extractedPath = filePath + '-extract-' + Date.now()
var options = {cwd: extractedPath}

mkdirp.sync(extractedPath, '0777')
fs.mkdirsSync(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 @@ -334,28 +331,18 @@ function extractDownload(filePath) {

function copyIntoPlace(extractedPath, targetPath) {
console.log('Removing', targetPath)
return kew.nfcall(rimraf, targetPath).then(function () {
return kew.nfcall(fs.remove, 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(ncp, file, targetPath)
return kew.nfcall(fs.move, 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.')
})
})
}
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "phantomjs",
"version": "1.9.13",
"version": "1.9.15",
"keywords": [
"phantomjs",
"headless",
"webkit"
],
"description": "Headless WebKit with JS API",
"homepage": "https://github.com/Obvious/phantomjs",
"homepage": "https://github.com/Medium/phantomjs",
"repository": {
"type": "git",
"url": "git://github.com/Obvious/phantomjs.git"
"url": "git://github.com/Medium/phantomjs.git"
},
"licenses": [
{
Expand Down Expand Up @@ -40,14 +40,12 @@
},
"dependencies": {
"adm-zip": "0.4.4",
"fs-extra": "~0.16.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 1bc7553

Please sign in to comment.