Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generators/repo/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import os from "os";
import fs from "fs/promises";
import ansiEscapes from "ansi-escapes";
import chalk from "chalk";
import { cleanDirectoryPath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader,isFilePath } from "../common/util";
import { cleanDirectoryPath, ensureRelativeBasePath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader,isFilePath } from "../common/util";
import { AssetRule, GitRemote, RepomanCommand, RepomanCommandOptions, RepoManifest } from "../models";
import { GitRepo } from "../tools/git";

Expand Down Expand Up @@ -411,6 +411,7 @@ export class GenerateCommand implements RepomanCommand {
let refPath = path.resolve(destFolderPath, path.normalize(match))
// Generate the relative path between the current processed file dir path & the referenced match path
let relativePath = path.relative(destFolderPath, refPath)
relativePath = ensureRelativeBasePath(relativePath);
// Finally convert the path back to a POSIX compatible path
relativePath = relativePath.split(path.sep).join(path.posix.sep)

Expand Down
13 changes: 13 additions & 0 deletions generators/repo/src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ export const cleanDirectoryPath = async (directoryPath: string, cleanGit: boolea
await del(patterns, { cwd: directoryPath, force: true, dot: true });
}

export const ensureRelativeBasePath = (input : string) => {
const basePath =`.${path.sep}`
if(!input.startsWith(basePath) && !input.startsWith(`.${basePath}`)) {
input = `${basePath}${input}`
}
else{
if (isDebug()) {
console.warn(chalk.yellowBright(` - ${input} already contains a relative base path.`));
}
}
return input;
}

export const toArray = (data: Buffer): string[] => {
if (!(data instanceof Buffer)) {
throw new Error("Not an instance of buffer");
Expand Down