Skip to content

Commit

Permalink
Clone the current version of the website.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed Dec 31, 2023
1 parent 17f7cf3 commit 0b99398
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { libyear } from 'francois-libyear';
import preferredPM from 'preferred-pm';
import semver from 'semver';
import { parseFile, parseRepositoryLine, replaceRepositoryWithSafeChar } from './utils.js';
import packageJSON from '../package.json' assert { type: 'json' };

export { parseFile, parseRepositoryLine, replaceRepositoryWithSafeChar };

Expand All @@ -24,7 +25,7 @@ const installCommand = {
};

export async function generateWebsite(repositoryUrl, env = {}, websiteUrl = 'https://github.com/Dependency-Drift-Tracker/dependency-drift-tracker.git') {
const tempDir = await cloneRepository(websiteUrl, simpleGit(), {});
const tempDir = await cloneRepository(websiteUrl, simpleGit(), {}, { '--branch': `v${packageJSON.version}` });
await exec('npm install --production=false', { cwd: tempDir });
await exec('npm run build -- --public-url ./', { cwd: tempDir, env: {
...process.env,
Expand Down Expand Up @@ -89,9 +90,9 @@ export function replaceRepositoryVariablesWithEnvVariables(repository, variables
}, repository);
}

export async function cloneRepository(repository, simpleGit, env) {
export async function cloneRepository(repository, simpleGit, env, gitOptions = {}) {
const tempRepositoryPath = await mkdtemp(join(tmpdir(), sep));
await simpleGit.clone(replaceRepositoryVariablesWithEnvVariables(repository, env), tempRepositoryPath, { '--depth': 1 })
await simpleGit.clone(replaceRepositoryVariablesWithEnvVariables(repository, env), tempRepositoryPath, { '--depth': 1, ...gitOptions })
return tempRepositoryPath;
}

Expand Down

0 comments on commit 0b99398

Please sign in to comment.