Tucker McKnight <tmcknight@instructure.com> | Sun Sep 28 2025
Allow relative paths to be used for repo location Previously, relative paths couldn't be used because it first `cd`s into the _site directory, and then tries to clone the site strait from the location that you give it for the repo. `process.cwd` is the directory of the current 11ty site, which should be the "base" location that the user is using for relative paths to their repositories. By putting the current directory before the repo location, we should get the full path to the repository.
52 53 54 55 56
eleventyConfig.on(
"eleventy.after",
async ({ directories, results, runMode, outputMode }) => {
// Check to see if there is already a repo in all of the locations
// that should have one.
for (let repoName in reposConfiguration.repos) {52 53 54 55 56 57
eleventyConfig.on(
"eleventy.after",
async ({ directories, results, runMode, outputMode }) => {
const cwd = process.cwd()
// Check to see if there is already a repo in all of the locations
// that should have one.
for (let repoName in reposConfiguration.repos) {59 60 61 62 63 64
if (repoConfig._type === "darcs") {
for (let branch in repoConfig.branches) {
const repoPath = eleventyConfig.dir.output + reposPath + "/" + eleventyConfig.getFilter("slugify")(repoName) + "/branches/" + branch
const originalLocation = repoConfig.branches[branch].location
// If it is there, do darcs pull
if (fsImport.existsSync(repoPath + "/_darcs")) {
await exec(`(cd ${repoPath} && darcs pull --no-interactive)`)59 60 61 62 63 64
if (repoConfig._type === "darcs") {
for (let branch in repoConfig.branches) {
const repoPath = eleventyConfig.dir.output + reposPath + "/" + eleventyConfig.getFilter("slugify")(repoName) + "/branches/" + branch
const originalLocation = cwd + "/" + repoConfig.branches[branch].location
// If it is there, do darcs pull
if (fsImport.existsSync(repoPath + "/_darcs")) {
await exec(`(cd ${repoPath} && darcs pull --no-interactive)`)79 80 81 82 83 84
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && ${fetchCommands}; git update-server-info)`)
} else {
// If it is not there, do git clone
const originalLocation = repoConfig.location
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/"} && git clone ${originalLocation} ${gitRepoName} --bare)`)
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && git update-server-info)`)
}79 80 81 82 83 84
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && ${fetchCommands}; git update-server-info)`)
} else {
// If it is not there, do git clone
const originalLocation = cwd + "/" + repoConfig.location
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/"} && git clone ${originalLocation} ${gitRepoName} --bare)`)
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && git update-server-info)`)
}