diff --git a/package-lock.json b/package-lock.json index 5655e67d5..3928ffaec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -729,9 +729,9 @@ "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==" }, "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", "dev": true }, "concat-map": { @@ -1161,7 +1161,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, "requires": { "homedir-polyfill": "^1.0.1" } @@ -1427,9 +1426,9 @@ } }, "fined": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/fined/-/fined-1.1.1.tgz", - "integrity": "sha512-jQp949ZmEbiYHk3gkbdtpJ0G1+kgtLQBNdP5edFP7Fh+WAYceLQz6yO1SBj72Xkg8GVyTB3bBzAYrHJVh5Xd5g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", "dev": true, "requires": { "expand-tilde": "^2.0.2", @@ -1528,15 +1527,23 @@ "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" }, "fs-extra": { - "version": "0.26.7", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", - "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "requires": { "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "dependencies": { + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + } } }, "fs-plus": { @@ -1986,7 +1993,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", - "dev": true, "requires": { "parse-passwd": "^1.0.0" } @@ -2079,9 +2085,9 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, "ipaddr.js": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", - "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", + "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", "dev": true }, "is-absolute": { @@ -2383,19 +2389,12 @@ } }, "keytar": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/keytar/-/keytar-4.4.1.tgz", - "integrity": "sha512-6xEe7ybXSR5EZC+z0GI2yqLYZjV1tyPQY2xSZ8rGsBxrrLEh8VR/Lfqv59uGX+I+W+OZxH0jCXN1dU1++ify4g==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/keytar/-/keytar-4.6.0.tgz", + "integrity": "sha512-8wWWTC62QHvUvgW/QYyJv7X0GFZfp2Ykr5n3PuXKADro0Sv2RKvuYxbkzoZvsw33EDNAKnUTSA0/KLGN/MbwDw==", "requires": { - "nan": "2.12.1", - "prebuild-install": "5.2.4" - }, - "dependencies": { - "nan": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.12.1.tgz", - "integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==" - } + "nan": "2.13.2", + "prebuild-install": "5.3.0" } }, "kind-of": { @@ -2412,6 +2411,14 @@ "graceful-fs": "^4.1.9" } }, + "klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "requires": { + "graceful-fs": "^4.1.11" + } + }, "lcid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", @@ -2587,16 +2594,16 @@ "dev": true }, "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==" + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" }, "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.40.0" } }, "mimic-response": { @@ -2664,6 +2671,20 @@ "decompress-zip": "0.3.x", "fs-extra": "0.26.7", "request": "2.x" + }, + "dependencies": { + "fs-extra": { + "version": "0.26.7", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", + "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0", + "klaw": "^1.0.0", + "path-is-absolute": "^1.0.0", + "rimraf": "^2.2.8" + } + } } }, "ms": { @@ -2677,33 +2698,6 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, - "mv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mv/-/mv-2.0.0.tgz", - "integrity": "sha1-jn7CtRh8hHFNd8jpg7HtKdejOhs=", - "requires": { - "mkdirp": "~0.3.5", - "ncp": "~0.4.2", - "rimraf": "~2.2.6" - }, - "dependencies": { - "mkdirp": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", - "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=" - }, - "ncp": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", - "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=" - }, - "rimraf": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=" - } - } - }, "nan": { "version": "2.13.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", @@ -2733,11 +2727,6 @@ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.1.tgz", "integrity": "sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==" }, - "ncp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.5.1.tgz", - "integrity": "sha1-dDmFMW49tFkoG1hxaehFc1oFQ58=" - }, "negotiator": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", @@ -2750,9 +2739,9 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" }, "node-abi": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.7.1.tgz", - "integrity": "sha512-OV8Bq1OrPh6z+Y4dqwo05HqrRL9YNF7QVMRfq1/pguwKLG+q9UB/Lk0x5qXjO23JjJg+/jqCHSTaG1P3tfKfuw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.8.0.tgz", + "integrity": "sha512-1/aa2clS0pue0HjckL62CsbhWWU35HARvBDXcJtYKbYR7LnIutmpxmXbuDMV9kEviD2lP/wACOgWmmwljghHyQ==", "requires": { "semver": "^5.4.1" } @@ -5728,13 +5717,12 @@ "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, "pascalcase": { @@ -5834,9 +5822,9 @@ "dev": true }, "prebuild-install": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.2.4.tgz", - "integrity": "sha512-CG3JnpTZXdmr92GW4zbcba4jkDha6uHraJ7hW4Fn8j0mExxwOKK20hqho8ZuBDCKYCHYIkFM1P2jhtG+KpP4fg==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.0.tgz", + "integrity": "sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg==", "requires": { "detect-libc": "^1.0.3", "expand-template": "^2.0.3", @@ -5878,13 +5866,13 @@ } }, "proxy-addr": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", - "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", + "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "dev": true, "requires": { "forwarded": "~0.1.2", - "ipaddr.js": "1.8.0" + "ipaddr.js": "1.9.0" } }, "psl": { @@ -6076,9 +6064,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -6775,13 +6763,13 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "~2.1.24" } }, "unc-path-regex": { @@ -6848,6 +6836,11 @@ } } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -7029,11 +7022,6 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "wrench": { - "version": "1.5.9", - "resolved": "https://registry.npmjs.org/wrench/-/wrench-1.5.9.tgz", - "integrity": "sha1-QRaRxjqbJTGxcAJnJ5veyiOyFCo=" - }, "xmlbuilder": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.3.tgz", diff --git a/package.json b/package.json index a89a06d9b..5d89c2dab 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,13 @@ "asar-require": "0.3.0", "async": "~0.2.8", "colors": "~0.6.1", + "expand-tilde": "^2.0.2", "first-mate": "6.2.0", - "fs-plus": "2.x", + "fs-extra": "^7.0.1", "git-utils": "^4.0", "hosted-git-info": "^2.1.4", "keytar": "^4.0", - "mv": "2.0.0", - "ncp": "~0.5.1", + "klaw-sync": "^6.0.0", "npm": "6.2.0", "open": "0.0.5", "q": "~0.9.7", @@ -45,7 +45,6 @@ "temp": "^0.8.3", "underscore-plus": "1.x", "wordwrap": "0.0.2", - "wrench": "~1.5.1", "yargs": "^3.23.0" }, "devDependencies": { diff --git a/script/download-node.js b/script/download-node.js index 18421f470..4af62e738 100755 --- a/script/download-node.js +++ b/script/download-node.js @@ -1,5 +1,4 @@ -var fs = require('fs'); -var mv = require('mv'); +var fs = require('fs-extra'); var zlib = require('zlib'); var path = require('path'); @@ -56,7 +55,7 @@ var copyNodeBinToLocation = function(callback, version, targetFilename, fromDire var arch = identifyArch(); var subDir = "node-" + version + "-" + process.platform + "-" + arch; var downloadedNodePath = path.join(fromDirectory, subDir, 'bin', 'node'); - return mv(downloadedNodePath, targetFilename, {mkdirp: true}, function(err) { + fs.move(downloadedNodePath, targetFilename, function(err) { if (err) { callback(err); return; diff --git a/spec/apm-cli-spec.coffee b/spec/apm-cli-spec.coffee index 0c9856787..8c9d7f4ff 100644 --- a/spec/apm-cli-spec.coffee +++ b/spec/apm-cli-spec.coffee @@ -1,6 +1,6 @@ +fs = require 'fs-extra' path = require 'path' temp = require 'temp' -fs = require 'fs' apm = require '../lib/apm-cli' describe 'apm command line interface', -> diff --git a/spec/ci-spec.coffee b/spec/ci-spec.coffee index 96dcddb13..0a5e1fdae 100644 --- a/spec/ci-spec.coffee +++ b/spec/ci-spec.coffee @@ -1,9 +1,8 @@ path = require 'path' -fs = require 'fs' +fs = require 'fs-extra' http = require 'http' temp = require 'temp' express = require 'express' -wrench = require 'wrench' CSON = require 'season' apm = require '../lib/apm-cli' @@ -62,7 +61,7 @@ describe 'apm ci', -> it 'installs dependency versions as specified by the lockfile', -> moduleDirectory = path.join temp.mkdirSync('apm-test-'), 'test-module-with-lockfile' - wrench.copyDirSyncRecursive path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory + fs.copySync path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory process.chdir moduleDirectory callback = jasmine.createSpy('callback') @@ -80,7 +79,7 @@ describe 'apm ci', -> it 'builds a native dependency correctly', -> moduleDirectory = path.join temp.mkdirSync('apm-test-'), 'test-module-with-native' - wrench.copyDirSyncRecursive path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory + fs.copySync path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory process.chdir moduleDirectory pjsonPath = path.join moduleDirectory, 'package.json' @@ -108,7 +107,7 @@ describe 'apm ci', -> it 'fails if the lockfile is not present', -> moduleDirectory = path.join temp.mkdirSync('apm-test-'), 'test-module' - wrench.copyDirSyncRecursive path.join(__dirname, 'fixtures', 'test-module'), moduleDirectory + fs.copySync path.join(__dirname, 'fixtures', 'test-module'), moduleDirectory process.chdir moduleDirectory callback = jasmine.createSpy('callback') @@ -120,7 +119,7 @@ describe 'apm ci', -> it 'fails if the lockfile is out of date', -> moduleDirectory = path.join temp.mkdirSync('apm-test-'), 'test-module-with-lockfile' - wrench.copyDirSyncRecursive path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory + fs.copySync path.join(__dirname, 'fixtures', 'test-module-with-lockfile'), moduleDirectory process.chdir moduleDirectory pjsonPath = path.join moduleDirectory, 'package.json' diff --git a/spec/clean-spec.coffee b/spec/clean-spec.coffee index 2b066ecd6..19fe4e083 100644 --- a/spec/clean-spec.coffee +++ b/spec/clean-spec.coffee @@ -1,9 +1,8 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' express = require 'express' http = require 'http' -wrench = require 'wrench' apm = require '../lib/apm-cli' describe 'apm clean', -> @@ -40,7 +39,7 @@ describe 'apm clean', -> process.env.npm_config_registry = 'http://localhost:3000/' moduleDirectory = path.join(temp.mkdirSync('apm-test-module-'), 'test-module-with-dependencies') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), moduleDirectory) + fs.copySync(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), moduleDirectory) process.chdir(moduleDirectory) live = true waitsFor -> live @@ -52,7 +51,7 @@ describe 'apm clean', -> it 'uninstalls any packages not referenced in the package.json', -> removedPath = path.join(moduleDirectory, 'node_modules', 'will-be-removed') - fs.makeTreeSync(removedPath) + fs.mkdirpSync(removedPath) fs.writeFileSync( path.join(removedPath, 'package.json'), '{"name": "will-be-removed", "version": "1.0.0", "dependencies": {}}', @@ -71,7 +70,7 @@ describe 'apm clean', -> it 'uninstalls a scoped package', -> removedPath = path.join(moduleDirectory, 'node_modules/@types/atom') - fs.makeTreeSync(removedPath) + fs.mkdirpSync(removedPath) fs.writeFileSync( path.join(removedPath, 'package.json'), '{"name": "@types/atom", "version": "1.0.0", "dependencies": {}}', diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 09340a74a..97d1f8f2a 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -1,5 +1,5 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' apm = require '../lib/apm-cli' @@ -30,7 +30,7 @@ describe "apm config", -> describe "apm config set", -> it "sets the value in the user config", -> - expect(fs.isFileSync(userConfigPath)).toBe false + expect(fs.existsSync(userConfigPath)).toBe false callback = jasmine.createSpy('callback') apm.run(['config', 'set', 'foo', 'bar'], callback) @@ -39,7 +39,7 @@ describe "apm config", -> callback.callCount is 1 runs -> - expect(fs.isFileSync(userConfigPath)).toBe true + expect(fs.statSync(userConfigPath).isFile()).toBe true callback.reset() apm.run(['config', 'get', 'foo'], callback) diff --git a/spec/develop-spec.coffee b/spec/develop-spec.coffee index 8d044c6b6..ece3645d8 100644 --- a/spec/develop-spec.coffee +++ b/spec/develop-spec.coffee @@ -1,5 +1,5 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' apm = require '../lib/apm-cli' @@ -60,7 +60,7 @@ describe "apm develop", -> describe "when the repository has already been cloned", -> it "links it to ATOM_HOME/dev/packages", -> - fs.makeTreeSync(repoPath) + fs.mkdirpSync(repoPath) fs.writeFileSync(path.join(repoPath, "package.json"), "") callback = jasmine.createSpy('callback') apm.run(['develop', "fake-package"], callback) diff --git a/spec/disable-spec.coffee b/spec/disable-spec.coffee index 55947d85c..1bcfd4c1b 100644 --- a/spec/disable-spec.coffee +++ b/spec/disable-spec.coffee @@ -1,5 +1,4 @@ -fs = require 'fs-plus' -wrench = require 'wrench' +fs = require 'fs-extra' path = require 'path' temp = require 'temp' CSON = require 'season' @@ -25,10 +24,10 @@ describe 'apm disable', -> packagesPath = path.join(atomHome, 'packages') packageSrcPath = path.join(__dirname, 'fixtures') - fs.makeTreeSync(packagesPath) - wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module'), path.join(packagesPath, 'test-module')) - wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module-two'), path.join(packagesPath, 'test-module-two')) - wrench.copyDirSyncRecursive(path.join(packageSrcPath, 'test-module-three'), path.join(packagesPath, 'test-module-three')) + fs.mkdirpSync(packagesPath) + fs.copySync(path.join(packageSrcPath, 'test-module'), path.join(packagesPath, 'test-module')) + fs.copySync(path.join(packageSrcPath, 'test-module-two'), path.join(packagesPath, 'test-module-two')) + fs.copySync(path.join(packageSrcPath, 'test-module-three'), path.join(packagesPath, 'test-module-three')) runs -> apm.run(['disable', 'test-module-two', 'not-installed', 'test-module-three'], callback) diff --git a/spec/enable-spec.coffee b/spec/enable-spec.coffee index af25ae780..a8672cf94 100644 --- a/spec/enable-spec.coffee +++ b/spec/enable-spec.coffee @@ -1,4 +1,3 @@ -fs = require 'fs' path = require 'path' temp = require 'temp' CSON = require 'season' diff --git a/spec/init-spec.coffee b/spec/init-spec.coffee index 5d4d64228..02f9ac4d1 100644 --- a/spec/init-spec.coffee +++ b/spec/init-spec.coffee @@ -2,7 +2,7 @@ path = require 'path' temp = require 'temp' CSON = require 'season' apm = require '../lib/apm-cli' -fs = require '../lib/fs' +fs = require 'fs-extra' describe "apm init", -> [packagePath, themePath, languagePath] = [] @@ -89,9 +89,9 @@ describe "apm init", -> it "generates the proper file structure", -> expect(fs.existsSync(packagePath)).toBeTruthy() - expect(fs.isFileSync(path.join(packagePath, 'settings', 'fake-package.cson'))).toBe true - expect(fs.isFileSync(path.join(packagePath, 'snippets', 'fake-package.cson'))).toBe true - expect(fs.isFileSync(path.join(packagePath, 'grammars', 'r.cson'))).toBe true + expect(fs.statSync(path.join(packagePath, 'settings', 'fake-package.cson')).isFile()).toBe true + expect(fs.statSync(path.join(packagePath, 'snippets', 'fake-package.cson')).isFile()).toBe true + expect(fs.statSync(path.join(packagePath, 'grammars', 'r.cson')).isFile()).toBe true expect(fs.existsSync(path.join(packagePath, 'command'))).toBeFalsy() expect(fs.existsSync(path.join(packagePath, 'README.md'))).toBeTruthy() expect(fs.existsSync(path.join(packagePath, 'package.json'))).toBeTruthy() diff --git a/spec/install-spec.coffee b/spec/install-spec.coffee index bfc23617d..6c205653c 100644 --- a/spec/install-spec.coffee +++ b/spec/install-spec.coffee @@ -1,10 +1,9 @@ path = require 'path' CSON = require 'season' -fs = require '../lib/fs' +fs = require 'fs-extra' temp = require 'temp' express = require 'express' http = require 'http' -wrench = require 'wrench' apm = require '../lib/apm-cli' Install = require '../lib/install' @@ -101,7 +100,7 @@ describe 'apm install', -> describe 'when a package name is specified', -> it 'installs the package', -> testModuleDirectory = path.join(atomHome, 'packages', 'test-module') - fs.makeTreeSync(testModuleDirectory) + fs.mkdirpSync(testModuleDirectory) existingTestModuleFile = path.join(testModuleDirectory, 'will-be-deleted.js') fs.writeFileSync(existingTestModuleFile, '') expect(fs.existsSync(existingTestModuleFile)).toBeTruthy() @@ -165,7 +164,7 @@ describe 'apm install', -> it 'installs the package with the new name and removes the old package', -> testRenameDirectory = path.join(atomHome, 'packages', 'test-rename') testModuleDirectory = path.join(atomHome, 'packages', 'test-module') - fs.makeTreeSync(testRenameDirectory) + fs.mkdirpSync(testRenameDirectory) expect(fs.existsSync(testRenameDirectory)).toBeTruthy() expect(fs.existsSync(testModuleDirectory)).toBeFalsy() @@ -220,7 +219,7 @@ describe 'apm install', -> describe 'when no path is specified', -> it 'installs all dependent modules', -> moduleDirectory = path.join(temp.mkdirSync('apm-test-module-'), 'test-module-with-dependencies') - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), moduleDirectory) + fs.copySync(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), moduleDirectory) process.chdir(moduleDirectory) callback = jasmine.createSpy('callback') apm.run(['install'], callback) @@ -259,10 +258,10 @@ describe 'apm install', -> callback.callCount is 1 runs -> - expect(fs.isFileSync(path.join(testModuleDirectory, 'index.js'))).toBeTruthy() + expect(fs.statSync(path.join(testModuleDirectory, 'index.js')).isFile()).toBeTruthy() if process.platform is 'win32' - expect(fs.isFileSync(path.join(testModuleDirectory, 'node_modules', '.bin', 'abin'))).toBeTruthy() + expect(fs.statSync(path.join(testModuleDirectory, 'node_modules', '.bin', 'abin')).isFile()).toBeTruthy() else expect(fs.realpathSync(path.join(testModuleDirectory, 'node_modules', '.bin', 'abin'))).toBe fs.realpathSync(path.join(testModuleDirectory, 'node_modules', 'test-module-with-bin', 'bin', 'abin.js')) @@ -279,7 +278,7 @@ describe 'apm install', -> runs -> expect(callback.argsForCall[0][0]).toBeFalsy() - expect(fs.isFileSync(path.join(testModuleDirectory, 'package.json'))).toBeTruthy() + expect(fs.statSync(path.join(testModuleDirectory, 'package.json')).isFile()).toBeTruthy() describe 'when a packages file is specified', -> it 'installs all the packages listed in the file', -> @@ -317,8 +316,8 @@ describe 'apm install', -> atomRepoPath = temp.mkdirSync('apm-repo-dir-') CSON.writeFileSync(path.join(atomRepoPath, 'package.json'), packageDependencies: 'test-module-with-dependencies': 'file:./packages/test-module-with-dependencies') packageDirectory = path.join(atomRepoPath, 'packages', 'test-module-with-dependencies') - fs.makeTreeSync(path.join(atomRepoPath, 'packages')) - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), packageDirectory) + fs.mkdirpSync(path.join(atomRepoPath, 'packages')) + fs.copySync(path.join(__dirname, 'fixtures', 'test-module-with-dependencies'), packageDirectory) originalPath = process.cwd() process.chdir(atomRepoPath) diff --git a/spec/link-spec.coffee b/spec/link-spec.coffee index 2d7c4fca4..3b3c46f6c 100644 --- a/spec/link-spec.coffee +++ b/spec/link-spec.coffee @@ -1,4 +1,4 @@ -fs = require 'fs' +fs = require 'fs-extra' path = require 'path' temp = require 'temp' apm = require '../lib/apm-cli' diff --git a/spec/list-spec.coffee b/spec/list-spec.coffee index 927eefe7e..eca1ab9b0 100644 --- a/spec/list-spec.coffee +++ b/spec/list-spec.coffee @@ -1,7 +1,6 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' -wrench = require 'wrench' apm = require '../lib/apm-cli' CSON = require 'season' @@ -18,7 +17,7 @@ createFakePackage = (type, metadata) -> when "user", "git" then "packages" when "dev" then path.join("dev", "packages") targetFolder = path.join(process.env.ATOM_HOME, packagesFolder, metadata.name) - fs.makeTreeSync targetFolder + fs.mkdirpSync targetFolder fs.writeFileSync path.join(targetFolder, 'package.json'), JSON.stringify(metadata) removeFakePackage = (type, name) -> @@ -61,7 +60,7 @@ describe 'apm list', -> sha: "abcdef1234567890" badPackagePath = path.join(process.env.ATOM_HOME, "packages", ".bin") - fs.makeTreeSync badPackagePath + fs.mkdirpSync badPackagePath fs.writeFileSync path.join(badPackagePath, "file.txt"), "some fake stuff" it 'lists the installed packages', -> @@ -80,8 +79,8 @@ describe 'apm list', -> describe 'enabling and disabling packages', -> beforeEach -> packagesPath = path.join(atomHome, 'packages') - fs.makeTreeSync(packagesPath) - wrench.copyDirSyncRecursive(path.join(__dirname, 'fixtures', 'test-module'), path.join(packagesPath, 'test-module')) + fs.mkdirpSync(packagesPath) + fs.copySync(path.join(__dirname, 'fixtures', 'test-module'), path.join(packagesPath, 'test-module')) configPath = path.join(atomHome, 'config.cson') CSON.writeFileSync configPath, '*': core: disabledPackages: ["test-module"] diff --git a/spec/publish-spec.coffee b/spec/publish-spec.coffee index d76e99aae..749b0f99e 100644 --- a/spec/publish-spec.coffee +++ b/spec/publish-spec.coffee @@ -1,5 +1,5 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' express = require 'express' http = require 'http' diff --git a/spec/rebuild-spec.coffee b/spec/rebuild-spec.coffee index a5dd3cc95..bcbb6b298 100644 --- a/spec/rebuild-spec.coffee +++ b/spec/rebuild-spec.coffee @@ -1,10 +1,8 @@ path = require 'path' CSON = require 'season' -fs = require 'fs-plus' temp = require 'temp' express = require 'express' http = require 'http' -wrench = require 'wrench' apm = require '../lib/apm-cli' describe 'apm rebuild', -> diff --git a/spec/stars-spec.coffee b/spec/stars-spec.coffee index 8186a4fba..14ad91a73 100644 --- a/spec/stars-spec.coffee +++ b/spec/stars-spec.coffee @@ -1,6 +1,6 @@ path = require 'path' express = require 'express' -fs = require 'fs-plus' +fs = require 'fs-extra' http = require 'http' temp = require 'temp' apm = require '../lib/apm-cli' diff --git a/spec/test-spec.coffee b/spec/test-spec.coffee index 932dacd6d..a8a6753b5 100644 --- a/spec/test-spec.coffee +++ b/spec/test-spec.coffee @@ -1,5 +1,4 @@ child_process = require 'child_process' -fs = require 'fs' path = require 'path' temp = require 'temp' apm = require '../lib/apm-cli' diff --git a/spec/uninstall-spec.coffee b/spec/uninstall-spec.coffee index 1b86c1f53..083ed055d 100644 --- a/spec/uninstall-spec.coffee +++ b/spec/uninstall-spec.coffee @@ -1,5 +1,5 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' apm = require '../lib/apm-cli' @@ -36,7 +36,7 @@ describe 'apm uninstall', -> it 'deletes the package', -> atomHome = temp.mkdirSync('apm-home-dir-') packagePath = path.join(atomHome, 'packages', 'test-package') - fs.makeTreeSync(path.join(packagePath, 'lib')) + fs.mkdirpSync(path.join(packagePath, 'lib')) fs.writeFileSync(path.join(packagePath, 'package.json'), "{}") process.env.ATOM_HOME = atomHome @@ -54,10 +54,10 @@ describe 'apm uninstall', -> it "deletes the packages from the dev packages folder", -> atomHome = temp.mkdirSync('apm-home-dir-') packagePath = path.join(atomHome, 'packages', 'test-package') - fs.makeTreeSync(path.join(packagePath, 'lib')) + fs.mkdirpSync(path.join(packagePath, 'lib')) fs.writeFileSync(path.join(packagePath, 'package.json'), "{}") devPackagePath = path.join(atomHome, 'dev', 'packages', 'test-package') - fs.makeTreeSync(path.join(devPackagePath, 'lib')) + fs.mkdirpSync(path.join(devPackagePath, 'lib')) fs.writeFileSync(path.join(devPackagePath, 'package.json'), "{}") process.env.ATOM_HOME = atomHome @@ -76,10 +76,10 @@ describe 'apm uninstall', -> it "deletes the packages from the both packages folders", -> atomHome = temp.mkdirSync('apm-home-dir-') packagePath = path.join(atomHome, 'packages', 'test-package') - fs.makeTreeSync(path.join(packagePath, 'lib')) + fs.mkdirpSync(path.join(packagePath, 'lib')) fs.writeFileSync(path.join(packagePath, 'package.json'), "{}") devPackagePath = path.join(atomHome, 'dev', 'packages', 'test-package') - fs.makeTreeSync(path.join(devPackagePath, 'lib')) + fs.mkdirpSync(path.join(devPackagePath, 'lib')) fs.writeFileSync(path.join(devPackagePath, 'package.json'), "{}") process.env.ATOM_HOME = atomHome diff --git a/spec/upgrade-spec.coffee b/spec/upgrade-spec.coffee index f1a5ab768..ffdceb46f 100644 --- a/spec/upgrade-spec.coffee +++ b/spec/upgrade-spec.coffee @@ -1,9 +1,8 @@ path = require 'path' -fs = require 'fs-plus' +fs = require 'fs-extra' temp = require 'temp' express = require 'express' http = require 'http' -wrench = require 'wrench' apm = require '../lib/apm-cli' apmRun = (args, callback) -> @@ -52,6 +51,7 @@ describe "apm upgrade", -> waitsFor -> done it "does not display updates for unpublished packages", -> + fs.mkdirpSync(path.join(packagesDir, 'not-published')) fs.writeFileSync(path.join(packagesDir, 'not-published', 'package.json'), JSON.stringify({name: 'not-published', version: '1.0', repository: 'https://github.com/a/b'})) callback = jasmine.createSpy('callback') @@ -65,6 +65,7 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).toContain 'empty' it "does not display updates for packages whose engine does not satisfy the installed Atom version", -> + fs.mkdirpSync(path.join(packagesDir, 'test-module')) fs.writeFileSync(path.join(packagesDir, 'test-module', 'package.json'), JSON.stringify({name: 'test-module', version: '0.3.0', repository: 'https://github.com/a/b'})) callback = jasmine.createSpy('callback') @@ -78,6 +79,7 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).toContain 'empty' it "displays the latest update that satisfies the installed Atom version", -> + fs.mkdirpSync(path.join(packagesDir, 'multi-module')) fs.writeFileSync(path.join(packagesDir, 'multi-module', 'package.json'), JSON.stringify({name: 'multi-module', version: '0.1.0', repository: 'https://github.com/a/b'})) callback = jasmine.createSpy('callback') @@ -91,6 +93,7 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).toContain 'multi-module 0.1.0 -> 0.3.0' it "does not display updates for packages already up to date", -> + fs.mkdirpSync(path.join(packagesDir, 'multi-module')) fs.writeFileSync(path.join(packagesDir, 'multi-module', 'package.json'), JSON.stringify({name: 'multi-module', version: '0.3.0', repository: 'https://github.com/a/b'})) callback = jasmine.createSpy('callback') @@ -104,6 +107,7 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).toContain 'empty' it "does display updates when the installed package's repository is not the same as the available package's repository", -> + fs.mkdirpSync(path.join(packagesDir, 'different-repo')) fs.writeFileSync(path.join(packagesDir, 'different-repo', 'package.json'), JSON.stringify({name: 'different-repo', version: '0.3.0', repository: 'https://github.com/world/hello'})) callback = jasmine.createSpy('callback') @@ -117,6 +121,8 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).toContain 'different-repo 0.3.0 -> 0.4.0' it "allows the package names to upgrade to be specified", -> + fs.mkdirpSync(path.join(packagesDir, 'multi-module')) + fs.mkdirpSync(path.join(packagesDir, 'different-repo')) fs.writeFileSync(path.join(packagesDir, 'multi-module', 'package.json'), JSON.stringify({name: 'multi-module', version: '0.1.0', repository: 'https://github.com/a/b'})) fs.writeFileSync(path.join(packagesDir, 'different-repo', 'package.json'), JSON.stringify({name: 'different-repo', version: '0.3.0', repository: 'https://github.com/world/hello'})) @@ -133,6 +139,7 @@ describe "apm upgrade", -> expect(console.log.argsForCall[1][0]).not.toContain 'multi-module 0.1.0 -> 0.3.0' it "does not display updates when the installed package's repository does not exist", -> + fs.mkdirpSync(path.join(packagesDir, 'different-repo')) fs.writeFileSync(path.join(packagesDir, 'different-repo', 'package.json'), JSON.stringify({name: 'different-repo', version: '0.3.0'})) callback = jasmine.createSpy('callback') @@ -159,6 +166,8 @@ describe "apm upgrade", -> it "ignores the commit SHA suffix in the version", -> fs.writeFileSync(path.join(atomApp, 'package.json'), JSON.stringify(version: '0.10.0-deadbeef')) + + fs.mkdirpSync(path.join(packagesDir, 'multi-module')) fs.writeFileSync(path.join(packagesDir, 'multi-module', 'package.json'), JSON.stringify({name: 'multi-module', version: '0.1.0', repository: 'https://github.com/a/b'})) callback = jasmine.createSpy('callback') diff --git a/src/apm-cli.coffee b/src/apm-cli.coffee index 21b2c47db..b44a68a69 100644 --- a/src/apm-cli.coffee +++ b/src/apm-cli.coffee @@ -1,4 +1,5 @@ {spawn} = require 'child_process' +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' @@ -6,22 +7,22 @@ colors = require 'colors' npm = require 'npm' yargs = require 'yargs' wordwrap = require 'wordwrap' +expandTilde = require 'expand-tilde' # Enable "require" scripts in asar archives require 'asar-require' config = require './apm' -fs = require './fs' git = require './git' setupTempDirectory = -> temp = require 'temp' tempDirectory = require('os').tmpdir() # Resolve ~ in tmp dir atom/atom#2271 - tempDirectory = path.resolve(fs.absolute(tempDirectory)) + tempDirectory = expandTilde(tempDirectory) temp.dir = tempDirectory try - fs.makeTreeSync(temp.dir) + fs.mkdirpSync(temp.dir) temp.track() setupTempDirectory() @@ -153,7 +154,8 @@ getPythonVersion = (callback) -> rootDir = process.env.SystemDrive ? 'C:\\' rootDir += '\\' unless rootDir[rootDir.length - 1] is '\\' pythonExe = path.resolve(rootDir, 'Python27', 'python.exe') - python = pythonExe if fs.isFileSync(pythonExe) + try + python = pythonExe if fs.statSync(pythonExe).isFile() python ?= 'python' diff --git a/src/apm.coffee b/src/apm.coffee index a78afa3e2..8d7a37e13 100644 --- a/src/apm.coffee +++ b/src/apm.coffee @@ -1,6 +1,7 @@ child_process = require 'child_process' -fs = require './fs' +fs = require 'fs-extra' path = require 'path' + npm = require 'npm' semver = require 'semver' @@ -104,6 +105,7 @@ module.exports = setupApmRcFile: -> try + fs.ensureFileSync(@getGlobalConfigPath()) fs.writeFileSync @getGlobalConfigPath(), """ ; This file is auto-generated and should not be edited since any ; modifications will be lost the next time any apm command is run. diff --git a/src/ci.coffee b/src/ci.coffee index b09c447e3..72a68f8e6 100644 --- a/src/ci.coffee +++ b/src/ci.coffee @@ -1,5 +1,5 @@ path = require 'path' -fs = require './fs' +fs = require 'fs-extra' yargs = require 'yargs' async = require 'async' _ = require 'underscore-plus' @@ -49,7 +49,7 @@ class Ci extends Command env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: config.getRustupHomeDirPath()}) env.USERPROFILE = env.HOME if config.isWin32() - fs.makeTreeSync(@atomDirectory) + fs.mkdirpSync(@atomDirectory) # node-gyp doesn't currently have an option for this so just set the # environment variable to bypass strict SSL diff --git a/src/clean.coffee b/src/clean.coffee index 0fe44c512..0f81fc10b 100644 --- a/src/clean.coffee +++ b/src/clean.coffee @@ -7,7 +7,6 @@ _ = require 'underscore-plus' Command = require './command' config = require './apm' -fs = require './fs' module.exports = class Clean extends Command diff --git a/src/dedupe.coffee b/src/dedupe.coffee index e41cead49..93a9bf185 100644 --- a/src/dedupe.coffee +++ b/src/dedupe.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' async = require 'async' @@ -6,7 +7,6 @@ yargs = require 'yargs' config = require './apm' Command = require './command' -fs = require './fs' module.exports = class Dedupe extends Command @@ -40,7 +40,7 @@ class Dedupe extends Command env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: config.getRustupHomeDirPath()}) env.USERPROFILE = env.HOME if config.isWin32() - fs.makeTreeSync(@atomDirectory) + fs.mkdirpSync(@atomDirectory) config.loadNpm (error, npm) => # node-gyp doesn't currently have an option for this so just set the # environment variable to bypass strict SSL @@ -87,8 +87,8 @@ class Dedupe extends Command @fork(@atomNpmPath, dedupeArgs, dedupeOptions, callback) createAtomDirectories: -> - fs.makeTreeSync(@atomDirectory) - fs.makeTreeSync(@atomNodeDirectory) + fs.mkdirpSync(@atomDirectory) + fs.mkdirpSync(@atomNodeDirectory) run: (options) -> {callback, cwd} = options diff --git a/src/develop.coffee b/src/develop.coffee index 99ec1f5c4..cc1991cc0 100644 --- a/src/develop.coffee +++ b/src/develop.coffee @@ -1,4 +1,4 @@ -fs = require 'fs' +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' diff --git a/src/fs.coffee b/src/fs.coffee deleted file mode 100644 index b5905e61a..000000000 --- a/src/fs.coffee +++ /dev/null @@ -1,42 +0,0 @@ -_ = require 'underscore-plus' -fs = require 'fs-plus' -ncp = require 'ncp' -rm = require 'rimraf' -wrench = require 'wrench' -path = require 'path' - -fsAdditions = - list: (directoryPath) -> - if fs.isDirectorySync(directoryPath) - try - fs.readdirSync(directoryPath) - catch e - [] - else - [] - - listRecursive: (directoryPath) -> - wrench.readdirSyncRecursive(directoryPath) - - cp: (sourcePath, destinationPath, callback) -> - rm destinationPath, (error) -> - if error? - callback(error) - else - ncp(sourcePath, destinationPath, callback) - - mv: (sourcePath, destinationPath, callback) -> - rm destinationPath, (error) -> - if error? - callback(error) - else - wrench.mkdirSyncRecursive(path.dirname(destinationPath), 0o755) - fs.rename(sourcePath, destinationPath, callback) - -module.exports = new Proxy({}, { - get: (target, key) -> - fsAdditions[key] or fs[key] - - set: (target, key, value) -> - fsAdditions[key] = value -}) diff --git a/src/git.coffee b/src/git.coffee index ca6b1e048..b97a1de98 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -1,9 +1,10 @@ {spawn} = require 'child_process' +fs = require 'fs-extra' path = require 'path' + _ = require 'underscore-plus' npm = require 'npm' config = require './apm' -fs = require './fs' addPortableGitToEnv = (env) -> localAppData = env.LOCALAPPDATA @@ -31,11 +32,18 @@ addGitBashToEnv = (env) -> if env.ProgramFiles gitPath = path.join(env.ProgramFiles, 'Git') - unless fs.isDirectorySync(gitPath) + try + unless fs.statSync(gitPath).isDirectory() + if env['ProgramFiles(x86)'] + gitPath = path.join(env['ProgramFiles(x86)'], 'Git') + catch error if env['ProgramFiles(x86)'] gitPath = path.join(env['ProgramFiles(x86)'], 'Git') - return unless fs.isDirectorySync(gitPath) + try + return unless fs.statSync(gitPath).isDirectory() + catch error + return cmdPath = path.join(gitPath, 'cmd') binPath = path.join(gitPath, 'bin') diff --git a/src/init.coffee b/src/init.coffee index e263ab8c7..8d56bb528 100644 --- a/src/init.coffee +++ b/src/init.coffee @@ -1,9 +1,10 @@ +fs = require 'fs-extra' path = require 'path' +klawSync = require 'klaw-sync' yargs = require 'yargs' Command = require './command' -fs = require './fs' module.exports = class Init extends Command @@ -114,9 +115,9 @@ class Init extends Command packageName ?= path.basename(packagePath) packageAuthor = process.env.GITHUB_USER or 'atom' - fs.makeTreeSync(packagePath) + fs.mkdirpSync(packagePath) - for childPath in fs.listRecursive(templatePath) + for {path: childPath, stats} in klawSync(templatePath) templateChildPath = path.resolve(templatePath, childPath) relativePath = templateChildPath.replace(templatePath, "") relativePath = relativePath.replace(/^\//, '') @@ -125,10 +126,10 @@ class Init extends Command sourcePath = path.join(packagePath, relativePath) continue if fs.existsSync(sourcePath) - if fs.isDirectorySync(templateChildPath) - fs.makeTreeSync(sourcePath) - else if fs.isFileSync(templateChildPath) - fs.makeTreeSync(path.dirname(sourcePath)) + if stats.isDirectory() + fs.mkdirpSync(sourcePath) + else if stats.isFile() + fs.mkdirpSync(path.dirname(sourcePath)) contents = fs.readFileSync(templateChildPath).toString() contents = @replacePackageNamePlaceholders(contents, packageName) contents = @replacePackageAuthorPlaceholders(contents, packageAuthor) diff --git a/src/install.coffee b/src/install.coffee index 8dfe30026..13b1f6547 100644 --- a/src/install.coffee +++ b/src/install.coffee @@ -1,4 +1,5 @@ assert = require 'assert' +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' @@ -6,13 +7,13 @@ async = require 'async' CSON = require 'season' yargs = require 'yargs' Git = require 'git-utils' +klawSync = require 'klaw-sync' semver = require 'semver' temp = require 'temp' hostedGitInfo = require 'hosted-git-info' config = require './apm' Command = require './command' -fs = require './fs' RebuildModuleCache = require './rebuild-module-cache' request = require './request' {isDeprecatedPackage} = require './deprecated-packages' @@ -68,7 +69,7 @@ class Install extends Command env = _.extend({}, process.env, {HOME: @atomNodeDirectory, RUSTUP_HOME: config.getRustupHomeDirPath()}) env.USERPROFILE = env.HOME if config.isWin32() - fs.makeTreeSync(@atomDirectory) + fs.mkdirpSync(@atomDirectory) # node-gyp doesn't currently have an option for this so just set the # environment variable to bypass strict SSL @@ -112,20 +113,27 @@ class Install extends Command if installGlobally installDirectory = temp.mkdirSync('apm-install-dir-') nodeModulesDirectory = path.join(installDirectory, 'node_modules') - fs.makeTreeSync(nodeModulesDirectory) + fs.mkdirpSync(nodeModulesDirectory) installOptions.cwd = installDirectory @fork @atomNpmPath, installArgs, installOptions, (code, stderr='', stdout='') => if code is 0 if installGlobally commands = [] - children = fs.readdirSync(nodeModulesDirectory) - .filter (dir) -> dir isnt ".bin" + children = fs.readdirSync(nodeModulesDirectory).filter (dir) -> dir isnt ".bin" assert.equal(children.length, 1, "Expected there to only be one child in node_modules") child = children[0] source = path.join(nodeModulesDirectory, child) destination = path.join(@atomPackagesDirectory, child) - commands.push (next) -> fs.cp(source, destination, next) + commands.push (next) -> + # emptyDir will pass `destination` as the first callback argument if it doesn't exist + # We expect the first argument to always be the next callback function, + # so don't call emptyDir unless `destination` exists + if fs.existsSync(destination) + fs.emptyDir(destination, next) + else + next() + commands.push (next) -> fs.copy(source, destination, next) commands.push (next) => @buildModuleCache(pack.name, next) commands.push (next) => @warmCompileCache(pack.name, next) @@ -395,9 +403,9 @@ class Install extends Command undefined createAtomDirectories: -> - fs.makeTreeSync(@atomDirectory) - fs.makeTreeSync(@atomPackagesDirectory) - fs.makeTreeSync(@atomNodeDirectory) + fs.mkdirpSync(@atomDirectory) + fs.mkdirpSync(@atomPackagesDirectory) + fs.mkdirpSync(@atomNodeDirectory) # Compile a sample native module to see if a useable native build toolchain # is instlalled and successfully detected. This will include both Python @@ -431,7 +439,11 @@ class Install extends Command packageNamesFromPath: (filePath) -> filePath = path.resolve(filePath) - unless fs.isFileSync(filePath) + isFile = false + try + isFile = fs.statSync(filePath).isFile() + + unless isFile throw new Error("File '#{filePath}' does not exist") packages = fs.readFileSync(filePath, 'utf8') @@ -451,14 +463,13 @@ class Install extends Command try CompileCache = require(path.join(resourcePath, 'src', 'compile-cache')) - onDirectory = (directoryPath) -> + isntNodeModules = ({path: directoryPath}) -> path.basename(directoryPath) isnt 'node_modules' - onFile = (filePath) => - try - CompileCache.addPathToCache(filePath, @atomDirectory) - - fs.traverseTreeSync(packageDirectory, onFile, onDirectory) + for {path: childPath, stats} in klawSync(packageDirectory, {filter: isntNodeModules}) + if stats.isFile() + try + CompileCache.addPathToCache(childPath, @atomDirectory) callback(null) isBundledPackage: (packageName, callback) -> @@ -533,13 +544,17 @@ class Install extends Command {name} = data.metadata targetDir = path.join(@atomPackagesDirectory, name) process.stdout.write "Moving #{name} to #{targetDir} " unless options.argv.json - fs.cp cloneDir, targetDir, (err) => + fs.emptyDir targetDir, (err) => if err next(err) else - @logSuccess() unless options.argv.json - json = {installPath: targetDir, metadata: data.metadata} - next(null, json) + fs.copy cloneDir, targetDir, (err) => + if err + next(err) + else + @logSuccess() unless options.argv.json + json = {installPath: targetDir, metadata: data.metadata} + next(null, json) iteratee = (currentData, task, next) -> task(currentData, next) async.reduce tasks, {}, iteratee, callback diff --git a/src/link.coffee b/src/link.coffee index 6d7588e58..d85f4c40b 100644 --- a/src/link.coffee +++ b/src/link.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' CSON = require 'season' @@ -5,7 +6,6 @@ yargs = require 'yargs' Command = require './command' config = require './apm' -fs = require './fs' module.exports = class Link extends Command @@ -47,8 +47,10 @@ class Link extends Command return try - fs.unlinkSync(targetPath) if fs.isSymbolicLinkSync(targetPath) - fs.makeTreeSync path.dirname(targetPath) + if fs.existsSync(targetPath) and fs.lstatSync(targetPath).isSymbolicLink() + fs.unlinkSync(targetPath) + + fs.mkdirpSync path.dirname(targetPath) fs.symlinkSync(linkPath, targetPath, 'junction') console.log "#{targetPath} -> #{linkPath}" callback() diff --git a/src/links.coffee b/src/links.coffee index 72a79b29f..d338984fb 100644 --- a/src/links.coffee +++ b/src/links.coffee @@ -1,10 +1,10 @@ +fs = require 'fs-extra' path = require 'path' yargs = require 'yargs' Command = require './command' config = require './apm' -fs = require './fs' tree = require './tree' module.exports = @@ -33,9 +33,14 @@ class Links extends Command getSymlinks: (directoryPath) -> symlinks = [] - for directory in fs.list(directoryPath) - symlinkPath = path.join(directoryPath, directory) - symlinks.push(symlinkPath) if fs.isSymbolicLinkSync(symlinkPath) + try + for directory in fs.readdirSync(directoryPath) + symlinkPath = path.join(directoryPath, directory) + try + symlinks.push(symlinkPath) if fs.lstatSync(symlinkPath).isSymbolicLink() + catch error + # readdir failed - just fall through and return an empty array + symlinks logLinks: (directoryPath) -> diff --git a/src/list.coffee b/src/list.coffee index 3b5befef1..770f22e51 100644 --- a/src/list.coffee +++ b/src/list.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' @@ -5,7 +6,6 @@ CSON = require 'season' yargs = require 'yargs' Command = require './command' -fs = require './fs' config = require './apm' tree = require './tree' {getRepository} = require "./packages" @@ -84,21 +84,30 @@ class List extends Command listPackages: (directoryPath, options) -> packages = [] - for child in fs.list(directoryPath) - continue unless fs.isDirectorySync(path.join(directoryPath, child)) - continue if child.match /^\./ - unless options.argv.links - continue if fs.isSymbolicLinkSync(path.join(directoryPath, child)) - - manifest = null - if manifestPath = CSON.resolve(path.join(directoryPath, child, 'package')) + try + for child in fs.readdirSync(directoryPath) + stats = null try - manifest = CSON.readFileSync(manifestPath) - manifest ?= {} - manifest.name = child - - continue unless @isPackageVisible(options, manifest) - packages.push(manifest) + stats = fs.lstatSync(path.join(directoryPath, child)) + catch error + continue + + continue unless stats.isDirectory() + continue if child.match /^\./ + unless options.argv.links + continue if stats.isSymbolicLink() + + manifest = null + if manifestPath = CSON.resolve(path.join(directoryPath, child, 'package')) + try + manifest = CSON.readFileSync(manifestPath) + manifest ?= {} + manifest.name = child + + continue unless @isPackageVisible(options, manifest) + packages.push(manifest) + catch error + # readdir failed - just fall through and return an empty array packages diff --git a/src/package-converter.coffee b/src/package-converter.coffee index a29106d6b..c91745662 100644 --- a/src/package-converter.coffee +++ b/src/package-converter.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' url = require 'url' zlib = require 'zlib' @@ -9,7 +10,6 @@ plist = require '@atom/plist' tar = require 'tar' temp = require 'temp' -fs = require './fs' request = require './request' # Convert a TextMate bundle to an Atom package @@ -116,7 +116,10 @@ class PackageConverter @writeFileSync(destinationPath, contents) normalizeFilenames: (directoryPath) -> - return unless fs.isDirectorySync(directoryPath) + try + return unless fs.statSync(directoryPath).isDirectory() + catch error + return for child in fs.readdirSync(directoryPath) childPath = path.join(directoryPath, child) @@ -137,9 +140,16 @@ class PackageConverter convertSnippets: (packageName, source) -> sourceSnippets = path.join(source, 'snippets') - unless fs.isDirectorySync(sourceSnippets) + try + unless fs.statSync(sourceSnippets).isDirectory() + sourceSnippets = path.join(source, 'Snippets') + catch error sourceSnippets = path.join(source, 'Snippets') - return unless fs.isDirectorySync(sourceSnippets) + + try + return unless fs.statSync(sourceSnippets).isDirectory() + catch error + return snippetsBySelector = {} destination = path.join(@destinationPath, 'snippets') @@ -177,9 +187,16 @@ class PackageConverter convertPreferences: (packageName, source) -> sourcePreferences = path.join(source, 'preferences') - unless fs.isDirectorySync(sourcePreferences) + try + unless fs.statSync(sourcePreferences).isDirectory() + sourcePreferences = path.join(source, 'Preferences') + catch error sourcePreferences = path.join(source, 'Preferences') - return unless fs.isDirectorySync(sourcePreferences) + + try + return unless fs.statSync(sourcePreferences).isDirectory() + catch error + return preferencesBySelector = {} destination = path.join(@destinationPath, 'settings') @@ -205,13 +222,20 @@ class PackageConverter convertGrammars: (source) -> sourceSyntaxes = path.join(source, 'syntaxes') - unless fs.isDirectorySync(sourceSyntaxes) + try + unless fs.statSync(sourceSyntaxes).isDirectory() + sourceSyntaxes = path.join(source, 'Syntaxes') + catch error sourceSyntaxes = path.join(source, 'Syntaxes') - return unless fs.isDirectorySync(sourceSyntaxes) + + try + return unless fs.statSync(sourceSyntaxes).isDirectory() + catch error + return destination = path.join(@destinationPath, 'grammars') for child in fs.readdirSync(sourceSyntaxes) childPath = path.join(sourceSyntaxes, child) - @convertFile(childPath, destination) if fs.isFileSync(childPath) + @convertFile(childPath, destination) if fs.statSync(childPath).isFile() @normalizeFilenames(destination) diff --git a/src/publish.coffee b/src/publish.coffee index a568adad2..e2e714973 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' url = require 'url' @@ -5,7 +6,6 @@ yargs = require 'yargs' Git = require 'git-utils' semver = require 'semver' -fs = require './fs' config = require './apm' Command = require './command' Login = require './login' @@ -225,7 +225,10 @@ class Publish extends Command loadMetadata: -> metadataPath = path.resolve('package.json') - unless fs.isFileSync(metadataPath) + try + unless fs.statSync(metadataPath).isFile() + throw new Error("No package.json file found at #{process.cwd()}/package.json") + catch error throw new Error("No package.json file found at #{process.cwd()}/package.json") try diff --git a/src/rebuild-module-cache.coffee b/src/rebuild-module-cache.coffee index 3366f10f7..730914b3e 100644 --- a/src/rebuild-module-cache.coffee +++ b/src/rebuild-module-cache.coffee @@ -1,9 +1,11 @@ +fs = require 'fs-extra' path = require 'path' + async = require 'async' yargs = require 'yargs' + Command = require './command' config = require './apm' -fs = require './fs' module.exports = class RebuildModuleCache extends Command @@ -49,18 +51,25 @@ class RebuildModuleCache extends Command {callback} = options commands = [] - fs.list(@atomPackagesDirectory).forEach (packageName) => - packageDirectory = path.join(@atomPackagesDirectory, packageName) - return if fs.isSymbolicLinkSync(packageDirectory) - return unless fs.isFileSync(path.join(packageDirectory, 'package.json')) - - commands.push (callback) => - process.stdout.write "Rebuilding #{packageName} module cache " - @rebuild packageDirectory, (error) => - if error? - @logFailure() - else - @logSuccess() - callback(error) + try + for packageName in fs.readdirSync(@atomPackagesDirectory) + packageDirectory = path.join(@atomPackagesDirectory, packageName) + try + continue if fs.lstatSync(packageDirectory).isSymbolicLink() + continue unless fs.statSync(path.join(packageDirectory, 'package.json')).isFile() + catch error + # If either error, we don't want to keep going + continue + + commands.push (callback) => + process.stdout.write "Rebuilding #{packageName} module cache " + @rebuild packageDirectory, (error) => + if error? + @logFailure() + else + @logSuccess() + callback(error) + catch error + # readdir failed - just fall through and use an empty array for commands async.waterfall(commands, callback) diff --git a/src/star.coffee b/src/star.coffee index 37d7dda89..5b2cb8cb4 100644 --- a/src/star.coffee +++ b/src/star.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' @@ -7,7 +8,6 @@ yargs = require 'yargs' config = require './apm' Command = require './command' -fs = require './fs' Login = require './login' Packages = require './packages' request = require './request' @@ -53,16 +53,22 @@ class Star extends Command callback() getInstalledPackageNames: -> - installedPackages = [] userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages') - for child in fs.list(userPackagesDirectory) - continue unless fs.isDirectorySync(path.join(userPackagesDirectory, child)) - - if manifestPath = CSON.resolve(path.join(userPackagesDirectory, child, 'package')) + installedPackages = [] + try + for child in fs.readdirSync(userPackagesDirectory) try - metadata = CSON.readFileSync(manifestPath) ? {} - if metadata.name and Packages.getRepository(metadata) - installedPackages.push metadata.name + continue unless fs.statSync(path.join(userPackagesDirectory, child)).isDirectory() + catch error + continue + + if manifestPath = CSON.resolve(path.join(userPackagesDirectory, child, 'package')) + try + metadata = CSON.readFileSync(manifestPath) ? {} + if metadata.name and Packages.getRepository(metadata) + installedPackages.push metadata.name + catch error + # readdir failed - just fall through and use an empty array for installedPackages _.uniq(installedPackages) diff --git a/src/test.coffee b/src/test.coffee index fae3d9328..79a03e808 100644 --- a/src/test.coffee +++ b/src/test.coffee @@ -1,10 +1,10 @@ +fs = require 'fs-extra' path = require 'path' yargs = require 'yargs' temp = require 'temp' Command = require './command' -fs = require './fs' module.exports = class Test extends Command diff --git a/src/theme-converter.coffee b/src/theme-converter.coffee index 265be8191..76aff48e6 100644 --- a/src/theme-converter.coffee +++ b/src/theme-converter.coffee @@ -1,6 +1,6 @@ +fs = require 'fs-extra' path = require 'path' url = require 'url' -fs = require './fs' request = require './request' TextMateTheme = require './text-mate-theme' @@ -25,10 +25,13 @@ class ThemeConverter callback(null, body) else sourcePath = path.resolve(@sourcePath) - if fs.isFileSync(sourcePath) - callback(null, fs.readFileSync(sourcePath, 'utf8')) - else - callback("TextMate theme file not found: #{sourcePath}") + try + if fs.statSync(sourcePath).isFile() + callback(null, fs.readFileSync(sourcePath, 'utf8')) + return + + # Not a file, or we errored + callback("TextMate theme file not found: #{sourcePath}") convert: (callback) -> @readTheme (error, themeContents) => @@ -39,6 +42,8 @@ class ThemeConverter catch error return callback(error) - fs.writeFileSync(path.join(@destinationPath, 'styles', 'base.less'), theme.getStylesheet()) - fs.writeFileSync(path.join(@destinationPath, 'styles', 'syntax-variables.less'), theme.getSyntaxVariables()) + stylesPath = path.join(@destinationPath, 'styles') + fs.mkdirpSync(stylesPath) + fs.writeFileSync(path.join(stylesPath, 'base.less'), theme.getStylesheet()) + fs.writeFileSync(path.join(stylesPath, 'syntax-variables.less'), theme.getSyntaxVariables()) callback() diff --git a/src/uninstall.coffee b/src/uninstall.coffee index eee9968d4..617e773f2 100644 --- a/src/uninstall.coffee +++ b/src/uninstall.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' async = require 'async' @@ -7,7 +8,6 @@ yargs = require 'yargs' auth = require './auth' Command = require './command' config = require './apm' -fs = require './fs' request = require './request' module.exports = diff --git a/src/unlink.coffee b/src/unlink.coffee index 7fa3e2f91..96b444471 100644 --- a/src/unlink.coffee +++ b/src/unlink.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' CSON = require 'season' @@ -5,7 +6,6 @@ yargs = require 'yargs' Command = require './command' config = require './apm' -fs = require './fs' module.exports = class Unlink extends Command @@ -39,7 +39,11 @@ class Unlink extends Command unlinkPath: (pathToUnlink) -> try process.stdout.write "Unlinking #{pathToUnlink} " - fs.unlinkSync(pathToUnlink) if fs.isSymbolicLinkSync(pathToUnlink) + isSymbolicLink = false + try + isSymbolicLink = fs.lstatSync(pathToUnlink).isSymbolicLink() + + fs.unlinkSync(pathToUnlink) if isSymbolicLink @logSuccess() catch error @logFailure() @@ -47,13 +51,14 @@ class Unlink extends Command unlinkAll: (options, callback) -> try - for child in fs.list(@devPackagesPath) + for child in fs.readdirSync(@devPackagesPath) packagePath = path.join(@devPackagesPath, child) - @unlinkPath(packagePath) if fs.isSymbolicLinkSync(packagePath) + @unlinkPath(packagePath) + unless options.argv.dev - for child in fs.list(@packagesPath) + for child in fs.readdirSync(@packagesPath) packagePath = path.join(@packagesPath, child) - @unlinkPath(packagePath) if fs.isSymbolicLinkSync(packagePath) + @unlinkPath(packagePath) callback() catch error callback(error) diff --git a/src/unpublish.coffee b/src/unpublish.coffee index daf2166a7..cfec5aa62 100644 --- a/src/unpublish.coffee +++ b/src/unpublish.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' readline = require 'readline' @@ -6,7 +7,6 @@ yargs = require 'yargs' auth = require './auth' Command = require './command' config = require './apm' -fs = require './fs' request = require './request' module.exports = diff --git a/src/upgrade.coffee b/src/upgrade.coffee index c36034fe5..b8db37edb 100644 --- a/src/upgrade.coffee +++ b/src/upgrade.coffee @@ -1,3 +1,4 @@ +fs = require 'fs-extra' path = require 'path' _ = require 'underscore-plus' @@ -9,7 +10,6 @@ Git = require 'git-utils' Command = require './command' config = require './apm' -fs = require './fs' Install = require './install' Packages = require './packages' request = require './request' @@ -47,9 +47,12 @@ class Upgrade extends Command getInstalledPackages: (options) -> packages = [] - for name in fs.list(@atomPackagesDirectory) - if pack = @getIntalledPackage(name) - packages.push(pack) + try + for name in fs.readdirSync(@atomPackagesDirectory) + if pack = @getIntalledPackage(name) + packages.push(pack) + catch error + # readdir failed - just fall through and use an empty array for packages packageNames = @packageNamesFromArgv(options.argv) if packageNames.length > 0 @@ -59,7 +62,11 @@ class Upgrade extends Command getIntalledPackage: (name) -> packageDirectory = path.join(@atomPackagesDirectory, name) - return if fs.isSymbolicLinkSync(packageDirectory) + try + return if fs.lstatSync(packageDirectory).isSymbolicLink() + catch error + return + try metadata = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'))) return metadata if metadata?.name and metadata?.version