Fixes #262 normalize artifact paths

This commit is contained in:
Nick Cipollo
2022-10-04 08:08:09 -04:00
parent 889eb279f8
commit f3ea29dca7
3 changed files with 22 additions and 0 deletions

13
lib/PathNormalizer.js Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathNormalizer = void 0;
const path_1 = __importDefault(require("path"));
class PathNormalizer {
static normalizePath(pathString) {
return path_1.default.resolve(pathString).split(path_1.default.sep).join("/");
}
}
exports.PathNormalizer = PathNormalizer;

View File

@@ -3,6 +3,7 @@ import {Globber, FileGlobber} from "./Globber";
import {Artifact} from "./Artifact";
import untildify from "untildify";
import {ArtifactPathValidator} from "./ArtifactPathValidator";
import {PathNormalizer} from "./PathNormalizer";
export interface ArtifactGlobber {
globArtifactString(artifact: string, contentType: string, errorsFailBuild: boolean): Artifact[]
@@ -19,6 +20,7 @@ export class FileArtifactGlobber implements ArtifactGlobber {
const split = /[,\n]/
return artifact.split(split)
.map(path => path.trimStart())
.map(path => PathNormalizer.normalizePath(path))
.map(path => FileArtifactGlobber.expandPath(path))
.map(pattern => this.globPattern(pattern, errorsFailBuild))
.map((globResult) => FileArtifactGlobber.validatePattern(errorsFailBuild, globResult[1], globResult[0]))

7
src/PathNormalizer.ts Normal file
View File

@@ -0,0 +1,7 @@
import path from "path";
export class PathNormalizer {
static normalizePath(pathString: string): string {
return pathString.split(path.sep).join("/")
}
}