diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.test.ts index 9c4cccb5dc..6637a68e4b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/azure.test.ts @@ -16,7 +16,7 @@ import fs from 'fs-extra'; import os from 'os'; -import { resolve } from 'path'; +import path from 'path'; import { AzurePreparer } from './azure'; import { getVoidLogger, Git } from '@backstage/backend-common'; @@ -37,8 +37,8 @@ describe('AzurePreparer', () => { }); const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp'; - const checkoutPath = resolve(workspacePath, 'checkout'); - const templatePath = resolve(workspacePath, 'template'); + const checkoutPath = path.resolve(workspacePath, 'checkout'); + const templatePath = path.resolve(workspacePath, 'template'); const prepareOptions = { url: 'https://dev.azure.com/backstage-org/backstage-project/_git/template-repo', @@ -54,7 +54,7 @@ describe('AzurePreparer', () => { username: 'notempty', }); expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath); - expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git')); + expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git')); }); it('calls the clone command with the correct arguments for a repository', async () => { @@ -100,17 +100,16 @@ describe('AzurePreparer', () => { }); it('moves the template from path if it is specified', async () => { - const path = './subdir'; await preparer.prepare({ url: `https://dev.azure.com/backstage-org/backstage-project/_git/template-repo?path=${encodeURIComponent( - path, + './subdir', )}`, logger, workspacePath, }); expect(fs.move).toHaveBeenCalledWith( - resolve(checkoutPath, 'subdir'), + path.resolve(checkoutPath, 'subdir'), templatePath, ); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.test.ts index cf08b888f4..beba62eb2a 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/bitbucket.test.ts @@ -17,7 +17,7 @@ import fs from 'fs-extra'; import { BitbucketPreparer } from './bitbucket'; import { getVoidLogger, Git } from '@backstage/backend-common'; -import { resolve } from 'path'; +import path from 'path'; import os from 'os'; jest.mock('fs-extra'); @@ -41,8 +41,8 @@ describe('BitbucketPreparer', () => { }); const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp'; - const checkoutPath = resolve(workspacePath, 'checkout'); - const templatePath = resolve(workspacePath, 'template'); + const checkoutPath = path.resolve(workspacePath, 'checkout'); + const templatePath = path.resolve(workspacePath, 'template'); const prepareOptions = { url: 'https://bitbucket.org/backstage-project/backstage-repo', @@ -58,7 +58,7 @@ describe('BitbucketPreparer', () => { ref: expect.any(String), }); expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath); - expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git')); + expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git')); }); it('calls the clone command with the correct arguments if an app password is provided for a repository', async () => { @@ -92,7 +92,7 @@ describe('BitbucketPreparer', () => { workspacePath, }); expect(fs.move).toHaveBeenCalledWith( - resolve(checkoutPath, '1', '2', '3'), + path.resolve(checkoutPath, '1', '2', '3'), templatePath, ); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/file.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/file.test.ts index ffb89b68b1..36be4d705b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/file.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/file.test.ts @@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common'; import fs from 'fs-extra'; import { FilePreparer } from './file'; import os from 'os'; -import path, { resolve } from 'path'; +import path from 'path'; jest.mock('fs-extra'); @@ -27,7 +27,7 @@ describe('File preparer', () => { const logger = getVoidLogger(); const preparer = new FilePreparer(); const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp'; - const checkoutPath = resolve(workspacePath, 'checkout'); + const checkoutPath = path.resolve(workspacePath, 'checkout'); await preparer.prepare({ url: 'file:///path/to/template', diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts index fd8ab1880e..a5fad5eaaa 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/github.test.ts @@ -16,7 +16,7 @@ import fs from 'fs-extra'; import os from 'os'; -import { resolve } from 'path'; +import path from 'path'; import { GithubPreparer } from './github'; import { getVoidLogger, Git } from '@backstage/backend-common'; @@ -24,8 +24,8 @@ jest.mock('fs-extra'); describe('GitHubPreparer', () => { const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp'; - const checkoutPath = resolve(workspacePath, 'checkout'); - const templatePath = resolve(workspacePath, 'template'); + const checkoutPath = path.resolve(workspacePath, 'checkout'); + const templatePath = path.resolve(workspacePath, 'template'); const mockGitClient = { clone: jest.fn(), @@ -57,7 +57,7 @@ describe('GitHubPreparer', () => { ref: expect.any(String), }); expect(fs.move).toHaveBeenCalledWith( - resolve(checkoutPath, 'templates', 'graphql-starter', 'template'), + path.resolve(checkoutPath, 'templates', 'graphql-starter', 'template'), templatePath, ); expect(fs.rmdir).toHaveBeenCalledWith('/tmp/template/.git'); @@ -77,7 +77,7 @@ describe('GitHubPreparer', () => { ref: 'master', }); expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath); - expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git')); + expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git')); }); it('calls the clone command with token', async () => { diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.test.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.test.ts index 6c04ce3a00..6ed4651e4f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/gitlab.test.ts @@ -15,7 +15,7 @@ */ import fs from 'fs-extra'; import os from 'os'; -import { resolve } from 'path'; +import path from 'path'; import { GitlabPreparer } from './gitlab'; import { getVoidLogger, Git } from '@backstage/backend-common'; @@ -23,8 +23,8 @@ jest.mock('fs-extra'); describe('GitLabPreparer', () => { const workspacePath = os.platform() === 'win32' ? 'C:\\tmp' : '/tmp'; - const checkoutPath = resolve(workspacePath, 'checkout'); - const templatePath = resolve(workspacePath, 'template'); + const checkoutPath = path.resolve(workspacePath, 'checkout'); + const templatePath = path.resolve(workspacePath, 'template'); const mockGitClient = { clone: jest.fn(), @@ -62,7 +62,7 @@ describe('GitLabPreparer', () => { }); expect(fs.move).toHaveBeenCalledWith(checkoutPath, templatePath); - expect(fs.rmdir).toHaveBeenCalledWith(resolve(templatePath, '.git')); + expect(fs.rmdir).toHaveBeenCalledWith(path.resolve(templatePath, '.git')); }); it(`clones the template from a sub directory if specified`, async () => { @@ -73,7 +73,7 @@ describe('GitLabPreparer', () => { workspacePath, }); expect(fs.move).toHaveBeenCalledWith( - resolve(checkoutPath, '1', '2', '3'), + path.resolve(checkoutPath, '1', '2', '3'), templatePath, ); });