Skip to content

Commit

Permalink
fix: stat will follow symlinks (#559)
Browse files Browse the repository at this point in the history
* fix: stat will follow symlinks

* test: another mock of lstat

* chore: adding types for SDR

* chore: bump and caret core

* chore: bump kit

* chore: adding types for SDR
  • Loading branch information
mshanemc committed Feb 7, 2022
1 parent 3e9198f commit f52e3cf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"node": ">=12.0.0"
},
"dependencies": {
"@salesforce/core": "2.33.1",
"@salesforce/kit": "^1.5.0",
"@salesforce/core": "^2.35.0",
"@salesforce/kit": "^1.5.32",
"@salesforce/ts-types": "^1.4.2",
"archiver": "^5.3.0",
"fast-xml-parser": "^3.17.4",
Expand Down
5 changes: 3 additions & 2 deletions src/resolve/treeContainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { join, dirname, basename, normalize, sep } from 'path';
import { Readable } from 'stream';
import { lstatSync, existsSync, readdirSync, createReadStream, readFileSync } from 'graceful-fs';
import { statSync, existsSync, readdirSync, createReadStream, readFileSync } from 'graceful-fs';
import * as unzipper from 'unzipper';
import { baseName, parseMetadataXml } from '../utils';
import { LibraryError } from '../errors';
Expand Down Expand Up @@ -86,7 +86,8 @@ export abstract class TreeContainer {
*/
export class NodeFSTreeContainer extends TreeContainer {
public isDirectory(fsPath: SourcePath): boolean {
return lstatSync(fsPath).isDirectory();
// use stat instead of lstat to follow symlinks
return statSync(fsPath).isDirectory();
}

public exists(fsPath: SourcePath): boolean {
Expand Down
2 changes: 1 addition & 1 deletion test/client/retrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Tooling Retrieve', () => {
});
sandboxStub.stub(fs, 'existsSync').returns(true);
// @ts-ignore
sandboxStub.stub(fs, 'lstatSync').returns({ isDirectory: () => false });
sandboxStub.stub(fs, 'statSync').returns({ isDirectory: () => false });
const mockFS = sandboxStub.stub(fs, 'readFileSync');
mockFS
.withArgs(path.join('file', 'path', 'MyTestClass.cls'), 'utf8')
Expand Down
2 changes: 1 addition & 1 deletion test/resolve/treeContainers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Tree Containers', () => {
});

it('should use expected Node API for isDirectory', () => {
const statStub = env.stub(fs, 'lstatSync');
const statStub = env.stub(fs, 'statSync');
// @ts-ignore lstat returns more than isDirectory function
statStub.withArgs(path).returns({ isDirectory: () => true });
expect(tree.isDirectory(path)).to.be.true;
Expand Down
49 changes: 32 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -555,21 +555,23 @@
mv "~2"
safe-json-stringify "~1"

"@salesforce/core@2.33.1":
version "2.33.1"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.33.1.tgz#23c22953174ad0e809b2f1c7b2881b5ba8a89d9c"
integrity sha512-jKVFYEvlV+loBoau5heBOVXmzsPO+RbYh6SPybJK6xF7khQmzu7+WAQbikY2eY8VaXcded2kka8L/FKuD/LKBg==
"@salesforce/core@^2.35.0":
version "2.35.0"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.35.0.tgz#15890d5b0294c56b5b435a4803f37f6a0c177893"
integrity sha512-eqBZtaHn3s3FsASjsrZ8T9e/TE+aHuB2DkuKDEierDYW5cSVqJyZ0ccMi9QKI7oQuPO1UHhcUyWmyezkdEjYzg==
dependencies:
"@salesforce/bunyan" "^2.0.0"
"@salesforce/kit" "^1.5.0"
"@salesforce/kit" "^1.5.17"
"@salesforce/schemas" "^1.0.1"
"@salesforce/ts-types" "^1.5.13"
"@salesforce/ts-types" "^1.5.20"
"@types/graceful-fs" "^4.1.5"
"@types/jsforce" "^1.9.35"
"@types/jsforce" "^1.9.38"
"@types/mkdirp" "^1.0.1"
archiver "^5.3.0"
debug "^3.1.0"
faye "^1.4.0"
graceful-fs "^4.2.4"
js2xmlparser "^4.0.1"
jsen "0.6.6"
jsforce "^1.11.0"
jsonwebtoken "8.5.0"
Expand Down Expand Up @@ -622,13 +624,14 @@
typedoc-plugin-external-module-name "~4.0.0"
typescript "^4.1.3"

"@salesforce/kit@^1.5.0":
version "1.5.8"
resolved "https://registry.yarnpkg.com/@salesforce/kit/-/kit-1.5.8.tgz#7a1abb46ffd6af8f35d4af8ee08a80eee9bcdbb1"
integrity sha512-tBq4eJfLvmtQT/jJElEN8bSJzKbVkY5yh9W/0CASTVw+aSOQ46Z8jYDtnYhRo+u5gDS4EiUQJKcq1J6xfkY7ZQ==
"@salesforce/kit@^1.5.17", "@salesforce/kit@^1.5.32":
version "1.5.32"
resolved "https://registry.yarnpkg.com/@salesforce/kit/-/kit-1.5.32.tgz#ed5925ea6cca23ef7cdef8086d9e663e50f98e93"
integrity sha512-5MIYLLx1Ee3eTcqEoqFXDCKXwtU8J5wo1QWyzb+BjReNGLVUuSc6Qi5JoCZtYGXeZpdBJmM3s9Y14QXr53ZmQw==
dependencies:
"@salesforce/ts-types" "^1.5.13"
tslib "^1.10.0"
"@salesforce/ts-types" "^1.5.20"
shx "^0.3.3"
tslib "^2.2.0"

"@salesforce/prettier-config@^0.0.2":
version "0.0.2"
Expand All @@ -649,7 +652,7 @@
sinon "^5.1.1"
tslib "^2.2.0"

"@salesforce/ts-types@^1.4.2", "@salesforce/ts-types@^1.5.13", "@salesforce/ts-types@^1.5.20":
"@salesforce/ts-types@^1.4.2", "@salesforce/ts-types@^1.5.20":
version "1.5.20"
resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-1.5.20.tgz#f6875a710ceca48223b240026a14af6d3b39882f"
integrity sha512-Ov6um4CWd63EvkRavkHG0J/P9XYL55sdkDWPMr7+AIgqh5flHxDRz09/C4e9M94aX30rzJxW4TVX6EBf4Cu2BQ==
Expand Down Expand Up @@ -806,7 +809,7 @@
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812"
integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ==

"@types/jsforce@^1.9.35", "@types/jsforce@^1.9.38":
"@types/jsforce@^1.9.38":
version "1.9.40"
resolved "https://registry.yarnpkg.com/@types/jsforce/-/jsforce-1.9.40.tgz#fc83fd4b5d8b67f19543cf8b86d24653e3f13ede"
integrity sha512-Zj53GKHjmrpbVmItS+XlenPFHtQAntADjt8g1zEs05dVfvfCHEty9NnlKTjwYA49BRNi4tD3S8TZb/gRgC0FyA==
Expand Down Expand Up @@ -3890,6 +3893,13 @@ js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

js2xmlparser@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-4.0.2.tgz#2a1fdf01e90585ef2ae872a01bc169c6a8d5e60a"
integrity sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==
dependencies:
xmlcreate "^2.0.4"

jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
Expand Down Expand Up @@ -5692,7 +5702,7 @@ [email protected], shelljs@^0.8.4, shelljs@^0.8.5, shelljs@~0.8.4:
interpret "^1.0.0"
rechoir "^0.6.2"

shx@^0.3.2:
shx@^0.3.2, shx@^0.3.3:
version "0.3.4"
resolved "https://registry.yarnpkg.com/shx/-/shx-0.3.4.tgz#74289230b4b663979167f94e1935901406e40f02"
integrity sha512-N6A9MLVqjxZYcVn8hLmtneQWIJtp8IKzMP4eMnx+nqkvXoqinUPCbUFLp2UcWTEIUONhlk0ewxr/jaVGlc+J+g==
Expand Down Expand Up @@ -6257,7 +6267,7 @@ tsconfig-paths@^3.11.0, tsconfig-paths@^3.12.0:
minimist "^1.2.0"
strip-bom "^3.0.0"

tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
Expand Down Expand Up @@ -6619,6 +6629,11 @@ xmlbuilder@~11.0.0:
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==

xmlcreate@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-2.0.4.tgz#0c5ab0f99cdd02a81065fa9cd8f8ae87624889be"
integrity sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==

xmldom-sfdx-encoding@^0.1.29:
version "0.1.30"
resolved "https://registry.yarnpkg.com/xmldom-sfdx-encoding/-/xmldom-sfdx-encoding-0.1.30.tgz#bc075757788573b8988facd6f7e7f073440b20b9"
Expand Down

0 comments on commit f52e3cf

Please sign in to comment.