-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use BSD tar on windows * Linting * Fallback to which tar if no system tar * Fix formatting * Bump prettier and typescript
- Loading branch information
Josh Gross
authored and
GitHub
committed
Dec 13, 2019
1 parent
4809f4a
commit 3854a40
Showing
8 changed files
with
146 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as exec from "@actions/exec"; | ||
import * as io from "@actions/io"; | ||
import * as tar from "../src/tar"; | ||
|
||
jest.mock("@actions/exec"); | ||
jest.mock("@actions/io"); | ||
|
||
beforeAll(() => { | ||
jest.spyOn(io, "which").mockImplementation(tool => { | ||
return Promise.resolve(tool); | ||
}); | ||
}); | ||
|
||
test("extract tar", async () => { | ||
const mkdirMock = jest.spyOn(io, "mkdirP"); | ||
const execMock = jest.spyOn(exec, "exec"); | ||
|
||
const archivePath = "cache.tar"; | ||
const targetDirectory = "~/.npm/cache"; | ||
await tar.extractTar(archivePath, targetDirectory); | ||
|
||
expect(mkdirMock).toHaveBeenCalledWith(targetDirectory); | ||
|
||
const IS_WINDOWS = process.platform === "win32"; | ||
const tarPath = IS_WINDOWS | ||
? `${process.env["windir"]}\\System32\\tar.exe` | ||
: "tar"; | ||
expect(execMock).toHaveBeenCalledTimes(1); | ||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [ | ||
"-xz", | ||
"-f", | ||
archivePath, | ||
"-C", | ||
targetDirectory | ||
]); | ||
}); | ||
|
||
test("create tar", async () => { | ||
const execMock = jest.spyOn(exec, "exec"); | ||
|
||
const archivePath = "cache.tar"; | ||
const sourceDirectory = "~/.npm/cache"; | ||
await tar.createTar(archivePath, sourceDirectory); | ||
|
||
const IS_WINDOWS = process.platform === "win32"; | ||
const tarPath = IS_WINDOWS | ||
? `${process.env["windir"]}\\System32\\tar.exe` | ||
: "tar"; | ||
expect(execMock).toHaveBeenCalledTimes(1); | ||
expect(execMock).toHaveBeenCalledWith(`"${tarPath}"`, [ | ||
"-cz", | ||
"-f", | ||
archivePath, | ||
"-C", | ||
sourceDirectory, | ||
"." | ||
]); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.