From 0b99398173bfcc0981f8251fe4b982463c02c900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Sun, 31 Dec 2023 13:00:47 +0100 Subject: [PATCH] Clone the current version of the website. --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 0cf3cca..cebf44d 100644 --- a/src/index.js +++ b/src/index.js @@ -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 }; @@ -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, @@ -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; }