Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Remove wrench, fs-plus in favor of fs-extra (Reviving #836) #894

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ad6abf9
Step 0: install fs-extra
50Wliu Apr 22, 2019
307c313
Step 1: use fs-extra in fs.coffee
50Wliu Apr 22, 2019
50c266b
Step 2: change all the things?
50Wliu Apr 22, 2019
a270ce7
Ugh
50Wliu Apr 22, 2019
4229775
More fixes
50Wliu Apr 23, 2019
ae36c63
Get rid of the remaining fs-plus functions
50Wliu Apr 23, 2019
fe6eac4
Fix initializing packages
50Wliu Apr 23, 2019
88ef0f5
That took longer than expected
50Wliu Apr 23, 2019
8c446df
Add missing mkdirps to upgrade-spec
50Wliu Apr 23, 2019
ae7c496
:fire: wrench
50Wliu Apr 23, 2019
cfb0c47
:fire: fs-plus, mv, ncp
50Wliu Apr 23, 2019
5e61195
Oops
50Wliu Apr 23, 2019
0f2fe0c
Don't know how I missed those
50Wliu Apr 23, 2019
fd56c14
copySync
50Wliu Apr 23, 2019
d258284
Debug it
50Wliu Apr 24, 2019
e633ef8
More debug
50Wliu Apr 24, 2019
c292527
Ah hah
50Wliu Apr 24, 2019
19d54d4
Bam, got it!
50Wliu Apr 24, 2019
cab9db2
Silence output
50Wliu Apr 24, 2019
88b6c20
Is it the link specs?
50Wliu Apr 24, 2019
e24d0da
Nope - somewhere in install-spec?
50Wliu Apr 24, 2019
c4664ac
Ah, yes
50Wliu Apr 24, 2019
f1330b8
Wow it really was just silencing the output
50Wliu Apr 25, 2019
f860435
If statSync triggers an exception, fallback to 32-bit Git
50Wliu Apr 25, 2019
51bc62a
Ensure no behavior changes
50Wliu Apr 25, 2019
0b71652
Merge branch 'master' into wl-fs-extra
50Wliu Apr 26, 2019
207531a
Wah
50Wliu Apr 27, 2019
c83d66d
Merge branch 'master' into wl-fs-extra
50Wliu Apr 27, 2019
e7c293f
Where is this node-gyp??
50Wliu Apr 27, 2019
1e9ad02
What about this
50Wliu Apr 27, 2019
675734c
Verbose it
50Wliu Apr 27, 2019
3e1d4ee
Wrong function...
50Wliu Apr 27, 2019
81547a9
Fix the bundle issues???
50Wliu Apr 27, 2019
8effbd9
Undo those require.resolve changes
50Wliu Apr 27, 2019
44b7567
Forgot the silenceOutput change
50Wliu Apr 27, 2019
3984f4c
Merge branch 'master' into wl-fs-extra
50Wliu May 8, 2019
efbe1d6
Merge remote-tracking branch 'origin/master' into wl-fs-extra
DeeDeeG Aug 10, 2020
c5bae69
src: More fs.makeTreeSync --> fs.mkdirpSync
DeeDeeG Aug 10, 2020
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
15,654 changes: 7,811 additions & 7,843 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -26,13 +26,13 @@
"asar-require": "0.3.0",
"async": "~0.2.8",
"colors": "~0.6.1",
"expand-tilde": "^2.0.2",
"first-mate": "^7.4.1",
"fs-plus": "2.x",
"git-utils": "^5.6.2",
"hosted-git-info": "^2.1.4",
"keytar": "^4.0",
"mv": "2.0.0",
"ncp": "~0.5.1",
"klaw-sync": "^6.0.0",
"npm": "^6.14.4",
"open": "0.0.5",
"q": "~0.9.7",
Expand All @@ -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": {
Expand Down
5 changes: 2 additions & 3 deletions 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');

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 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', ->
Expand Down
11 changes: 5 additions & 6 deletions 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'

Expand Down Expand Up @@ -64,7 +63,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')
Expand All @@ -82,7 +81,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'
Expand Down Expand Up @@ -110,7 +109,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')
Expand All @@ -122,7 +121,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'
Expand Down
9 changes: 4 additions & 5 deletions 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', ->
Expand Down Expand Up @@ -42,7 +41,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
Expand All @@ -54,7 +53,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": {}}',
Expand All @@ -73,7 +72,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": {}}',
Expand Down
6 changes: 3 additions & 3 deletions 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'

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions 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'

Expand Down Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions 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'
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion spec/enable-spec.coffee
@@ -1,4 +1,3 @@
fs = require 'fs'
path = require 'path'
temp = require 'temp'
CSON = require 'season'
Expand Down
8 changes: 4 additions & 4 deletions spec/init-spec.coffee
Expand Up @@ -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] = []
Expand Down Expand Up @@ -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()
Expand Down
19 changes: 9 additions & 10 deletions 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'

Expand Down Expand Up @@ -103,7 +102,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()
Expand Down Expand Up @@ -167,7 +166,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()

Expand Down Expand Up @@ -222,7 +221,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)
Expand Down Expand Up @@ -261,10 +260,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'))

Expand All @@ -281,7 +280,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', ->
Expand Down Expand Up @@ -319,8 +318,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)

Expand Down
2 changes: 1 addition & 1 deletion 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'
Expand Down
11 changes: 5 additions & 6 deletions 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'

Expand All @@ -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) ->
Expand Down Expand Up @@ -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', ->
Expand Down Expand Up @@ -93,8 +92,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"]
Expand Down
2 changes: 1 addition & 1 deletion 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'
Expand Down
2 changes: 0 additions & 2 deletions 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', ->
Expand Down
2 changes: 1 addition & 1 deletion 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'
Expand Down
1 change: 0 additions & 1 deletion 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'
Expand Down