Remove untildify

This commit is contained in:
Nick Cipollo
2025-12-02 08:29:48 -05:00
parent 23d2cc4c27
commit be9a4fac3a
9 changed files with 74 additions and 54 deletions

View File

@@ -3,7 +3,7 @@ const warnMock = jest.fn()
import { FileArtifactGlobber } from "../src/ArtifactGlobber" import { FileArtifactGlobber } from "../src/ArtifactGlobber"
import { Globber } from "../src/Globber" import { Globber } from "../src/Globber"
import { Artifact } from "../src/Artifact" import { Artifact } from "../src/Artifact"
import untildify = require("untildify") import { expandTilde } from "../src/PathExpander"
const contentType = "raw" const contentType = "raw"
const globMock = jest.fn() const globMock = jest.fn()
@@ -39,7 +39,7 @@ describe("ArtifactGlobber", () => {
const expectedArtifacts = globResults.map((path) => new Artifact(path, contentType)) const expectedArtifacts = globResults.map((path) => new Artifact(path, contentType))
expect(globber.globArtifactString("~/path", "raw", false)).toEqual(expectedArtifacts) expect(globber.globArtifactString("~/path", "raw", false)).toEqual(expectedArtifacts)
expect(globMock).toHaveBeenCalledWith(untildify("~/path")) expect(globMock).toHaveBeenCalledWith(expandTilde("~/path"))
expect(warnMock).not.toHaveBeenCalled() expect(warnMock).not.toHaveBeenCalled()
}) })

View File

@@ -0,0 +1,42 @@
import os from "os"
import { expandTilde } from "../src/PathExpander"
describe("PathExpander", () => {
describe("expandTilde", () => {
it("expands ~ at the start of a path", () => {
const result = expandTilde("~/documents")
expect(result).toBe(`${os.homedir()}/documents`)
})
it("expands ~ with backslash separator", () => {
const result = expandTilde("~\\documents")
expect(result).toBe(`${os.homedir()}\\documents`)
})
it("expands standalone ~", () => {
const result = expandTilde("~")
expect(result).toBe(os.homedir())
})
it("does not expand ~ in the middle of a path", () => {
const result = expandTilde("/home/~user/documents")
expect(result).toBe("/home/~user/documents")
})
it("does not expand ~username patterns", () => {
const result = expandTilde("~username/documents")
expect(result).toBe("~username/documents")
})
it("returns path unchanged when no tilde present", () => {
const result = expandTilde("/absolute/path")
expect(result).toBe("/absolute/path")
})
it("returns relative path unchanged", () => {
const result = expandTilde("relative/path")
expect(result).toBe("relative/path")
})
})
})

45
dist/index.js vendored
View File

@@ -349,15 +349,12 @@ var __importStar = (this && this.__importStar) || (function () {
return result; return result;
}; };
})(); })();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.FileArtifactGlobber = void 0; exports.FileArtifactGlobber = void 0;
const core = __importStar(__nccwpck_require__(5357)); const core = __importStar(__nccwpck_require__(5357));
const Globber_1 = __nccwpck_require__(611); const Globber_1 = __nccwpck_require__(611);
const Artifact_1 = __nccwpck_require__(5964); const Artifact_1 = __nccwpck_require__(5964);
const untildify_1 = __importDefault(__nccwpck_require__(2120)); const PathExpander_1 = __nccwpck_require__(4858);
const ArtifactPathValidator_1 = __nccwpck_require__(8969); const ArtifactPathValidator_1 = __nccwpck_require__(8969);
const PathNormalizer_1 = __nccwpck_require__(4802); const PathNormalizer_1 = __nccwpck_require__(4802);
class FileArtifactGlobber { class FileArtifactGlobber {
@@ -400,7 +397,7 @@ class FileArtifactGlobber {
throw Error(`Artifact pattern :${pattern} did not match any files`); throw Error(`Artifact pattern :${pattern} did not match any files`);
} }
static expandPath(path) { static expandPath(path) {
return (0, untildify_1.default)(path); return (0, PathExpander_1.expandTilde)(path);
} }
} }
exports.FileArtifactGlobber = FileArtifactGlobber; exports.FileArtifactGlobber = FileArtifactGlobber;
@@ -1026,6 +1023,24 @@ class CoreOutputs {
exports.CoreOutputs = CoreOutputs; exports.CoreOutputs = CoreOutputs;
/***/ }),
/***/ 4858:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.expandTilde = expandTilde;
const os_1 = __importDefault(__nccwpck_require__(857));
function expandTilde(path) {
return path.replace(/^~(?=$|\/|\\)/, os_1.default.homedir());
}
/***/ }), /***/ }),
/***/ 4802: /***/ 4802:
@@ -31415,26 +31430,6 @@ exports.getUserAgent = getUserAgent;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
/***/ }),
/***/ 2120:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
const os = __nccwpck_require__(857);
const homeDirectory = os.homedir();
module.exports = pathWithTilde => {
if (typeof pathWithTilde !== 'string') {
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
}
return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde;
};
/***/ }), /***/ }),
/***/ 5518: /***/ 5518:

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

13
dist/licenses.txt vendored
View File

@@ -754,19 +754,6 @@ Permission to use, copy, modify, and/or distribute this software for any purpose
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
untildify
MIT
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wrappy wrappy
ISC ISC
The ISC License The ISC License

View File

@@ -51,8 +51,7 @@
"@actions/core": "^1.11.1", "@actions/core": "^1.11.1",
"@actions/github": "^6.0.1", "@actions/github": "^6.0.1",
"@types/node": "^24.9.2", "@types/node": "^24.9.2",
"glob": "^13.0.0", "glob": "^13.0.0"
"untildify": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "2.3.8", "@biomejs/biome": "2.3.8",

9
pnpm-lock.yaml generated
View File

@@ -26,9 +26,6 @@ importers:
glob: glob:
specifier: ^10.5.0 specifier: ^10.5.0
version: 10.5.0 version: 10.5.0
untildify:
specifier: ^4.0.0
version: 4.0.0
devDependencies: devDependencies:
'@biomejs/biome': '@biomejs/biome':
specifier: 2.3.8 specifier: 2.3.8
@@ -1426,10 +1423,6 @@ packages:
unrs-resolver@1.11.1: unrs-resolver@1.11.1:
resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==} resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==}
untildify@4.0.0:
resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==}
engines: {node: '>=8'}
update-browserslist-db@1.1.4: update-browserslist-db@1.1.4:
resolution: {integrity: sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==} resolution: {integrity: sha512-q0SPT4xyU84saUX+tomz1WLkxUbuaJnR1xWt17M7fJtEJigJeWUNGUqrauFXsHnqev9y9JTRGwk13tFBuKby4A==}
hasBin: true hasBin: true
@@ -3093,8 +3086,6 @@ snapshots:
'@unrs/resolver-binding-win32-ia32-msvc': 1.11.1 '@unrs/resolver-binding-win32-ia32-msvc': 1.11.1
'@unrs/resolver-binding-win32-x64-msvc': 1.11.1 '@unrs/resolver-binding-win32-x64-msvc': 1.11.1
untildify@4.0.0: {}
update-browserslist-db@1.1.4(browserslist@4.28.0): update-browserslist-db@1.1.4(browserslist@4.28.0):
dependencies: dependencies:
browserslist: 4.28.0 browserslist: 4.28.0

View File

@@ -1,7 +1,7 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import { Globber, FileGlobber } from "./Globber" import { Globber, FileGlobber } from "./Globber"
import { Artifact } from "./Artifact" import { Artifact } from "./Artifact"
import untildify from "untildify" import { expandTilde } from "./PathExpander"
import { ArtifactPathValidator } from "./ArtifactPathValidator" import { ArtifactPathValidator } from "./ArtifactPathValidator"
import { PathNormalizer } from "./PathNormalizer" import { PathNormalizer } from "./PathNormalizer"
@@ -55,6 +55,6 @@ export class FileArtifactGlobber implements ArtifactGlobber {
} }
private static expandPath(path: string): string { private static expandPath(path: string): string {
return untildify(path) return expandTilde(path)
} }
} }

6
src/PathExpander.ts Normal file
View File

@@ -0,0 +1,6 @@
import os from "os"
export function expandTilde(path: string): string {
return path.replace(/^~(?=$|\/|\\)/, os.homedir())
}