From d0ed25196c8d2bd7f32f9055d4cfbb01808eb05a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 19 Feb 2021 14:51:14 +0100 Subject: [PATCH] scaffolder-backend: fix file path resolution for templates with a file location Co-authored-by: Johan Haals --- .changeset/slimy-singers-return.md | 5 +++++ .../src/scaffolder/tasks/TemplateConverter.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/slimy-singers-return.md diff --git a/.changeset/slimy-singers-return.md b/.changeset/slimy-singers-return.md new file mode 100644 index 0000000000..c5fc60aaa2 --- /dev/null +++ b/.changeset/slimy-singers-return.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Fixed file path resolution for templates with a file location diff --git a/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts b/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts index 8019b676b5..7f76ac33d0 100644 --- a/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts +++ b/plugins/scaffolder-backend/src/scaffolder/tasks/TemplateConverter.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { resolve as resolvePath } from 'path'; +import { resolve as resolvePath, dirname } from 'path'; import { JsonValue } from '@backstage/config'; import { TemplateEntityV1alpha1 } from '@backstage/catalog-model'; import { Logger } from 'winston'; @@ -39,7 +39,7 @@ export function templateEntityToSpec( let url: string; if (protocol === 'file') { - const path = resolvePath(location, template.spec.path || '.'); + const path = resolvePath(dirname(location), template.spec.path || '.'); url = `file://${path}`; } else {