chore: remove path sep conversion

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-19 00:59:04 +01:00
parent 2038d87306
commit ed087e5b0d
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
10 changed files with 22 additions and 22 deletions

View File

@ -24,8 +24,8 @@ import {Context} from '../../src/context';
const fixturesDir = path.join(__dirname, '..', 'fixtures');
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest').split(path.sep).join(path.posix.sep);
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildkit-config-jest');
const tmpName = path.join(tmpDir, '.tmpname-jest');
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
if (!fs.existsSync(tmpDir)) {
@ -50,7 +50,7 @@ describe('resolve', () => {
['debug = true', false, 'debug = true', null],
[`notfound.toml`, true, '', new Error('config file notfound.toml not found')],
[
`${path.join(fixturesDir, 'buildkitd.toml').split(path.sep).join(path.posix.sep)}`,
`${path.join(fixturesDir, 'buildkitd.toml')}`,
true,
`debug = true
[registry."docker.io"]

View File

@ -27,8 +27,8 @@ import {Context} from '../../src/context';
import {Cert} from '../../src/types/buildx';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
const tmpName = path.join(tmpDir, '.tmpname-jest');
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
if (!fs.existsSync(tmpDir)) {

View File

@ -25,8 +25,8 @@ import {Inputs} from '../../src/buildx/inputs';
const fixturesDir = path.join(__dirname, '..', 'fixtures');
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest').split(path.sep).join(path.posix.sep);
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-inputs-jest');
const tmpName = path.join(tmpDir, '.tmpname-jest');
const metadata = `{
"containerimage.config.digest": "sha256:059b68a595b22564a1cbc167af369349fdc2ecc1f7bc092c2235cbf601a795fd",
"containerimage.digest": "sha256:b09b9482c72371486bb2c1d2c2a2633ed1d0b8389e12c8d52b9e052725c0c83c"
@ -175,7 +175,7 @@ describe('resolveBuildSecret', () => {
['aaaaaaaa', false, '', '', new Error('aaaaaaaa is not a valid secret')],
['aaaaaaaa=', false, '', '', new Error('aaaaaaaa= is not a valid secret')],
['=bbbbbbb', false, '', '', new Error('=bbbbbbb is not a valid secret')],
[`foo=${path.join(fixturesDir, 'secret.txt').split(path.sep).join(path.posix.sep)}`, true, 'foo', 'bar', null],
[`foo=${path.join(fixturesDir, 'secret.txt')}`, true, 'foo', 'bar', null],
[`notfound=secret`, true, '', '', new Error('secret file secret not found')]
])('given %p key and %p secret', async (kvp: string, file: boolean, exKey: string, exValue: string, error: Error) => {
try {

View File

@ -23,7 +23,7 @@ import osm = require('os');
import {Install} from '../../src/buildx/install';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join(process.env.TEMP || '/tmp', 'buildx-jest');
beforeEach(() => {
jest.clearAllMocks();

View File

@ -22,8 +22,8 @@ import {describe, expect, jest, it, beforeEach, afterEach} from '@jest/globals';
import {Context} from '../src/context';
// prettier-ignore
const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest').split(path.sep).join(path.posix.sep);
const tmpName = path.join(tmpDir, '.tmpname-jest').split(path.sep).join(path.posix.sep);
const tmpDir = path.join(process.env.TEMP || '/tmp', 'context-jest');
const tmpName = path.join(tmpDir, '.tmpname-jest');
jest.spyOn(Context.prototype, 'tmpDir').mockImplementation((): string => {
if (!fs.existsSync(tmpDir)) {

View File

@ -60,18 +60,18 @@ describe('isAvailable', () => {
});
describe('printVersion', () => {
it('docker cli', () => {
it('docker cli', async () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printVersion(false).catch(() => {
await Docker.printVersion(false).catch(() => {
// noop
});
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
failOnStdErr: false
});
});
it('standalone', () => {
it('standalone', async () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printVersion(true).catch(() => {
await Docker.printVersion(true).catch(() => {
// noop
});
expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], {

View File

@ -18,13 +18,13 @@ import fs from 'fs';
import os from 'os';
import path from 'path';
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
process.env = Object.assign({}, process.env, {
TEMP: tmpDir,
GITHUB_REPOSITORY: 'docker/actions-toolkit',
RUNNER_TEMP: path.join(tmpDir, 'runner-temp').split(path.sep).join(path.posix.sep),
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache').split(path.sep).join(path.posix.sep)
RUNNER_TEMP: path.join(tmpDir, 'runner-temp'),
RUNNER_TOOL_CACHE: path.join(tmpDir, 'runner-tool-cache')
}) as {
[key: string]: string;
};

View File

@ -29,11 +29,11 @@ export class Inputs {
}
public getBuildImageIDFilePath(): string {
return path.join(this.context.tmpDir(), 'iidfile').split(path.sep).join(path.posix.sep);
return path.join(this.context.tmpDir(), 'iidfile');
}
public getBuildMetadataFilePath(): string {
return path.join(this.context.tmpDir(), 'metadata-file').split(path.sep).join(path.posix.sep);
return path.join(this.context.tmpDir(), 'metadata-file');
}
public resolveBuildImageID(): string | undefined {

View File

@ -89,7 +89,7 @@ export class Install {
let toolPath: string;
toolPath = tc.find('buildx', vspec);
if (!toolPath) {
const outputDir = path.join(this.context.tmpDir(), 'build-cache').split(path.sep).join(path.posix.sep);
const outputDir = path.join(this.context.tmpDir(), 'build-cache');
const buildCmd = await this.buildCommand(gitContext, outputDir);
toolPath = await exec
.getExecOutput(buildCmd.command, buildCmd.args, {

View File

@ -27,7 +27,7 @@ export class Context {
public buildGitContext: string;
public provenanceBuilderID: string;
private readonly _tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
private readonly _tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-'));
constructor() {
this.gitRef = github.context.ref;