Skip to content

Commit

Permalink
Fixes #262 normalize artifact paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ncipollo committed Oct 4, 2022
1 parent 889eb27 commit f3ea29d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/PathNormalizer.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions src/ArtifactGlobber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand All @@ -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]))
Expand Down
7 changes: 7 additions & 0 deletions src/PathNormalizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import path from "path";

export class PathNormalizer {
static normalizePath(pathString: string): string {
return pathString.split(path.sep).join("/")
}
}

0 comments on commit f3ea29d

Please sign in to comment.