/
githubmirror
/
Leaflet
Обзор
Документация
Войти
/
githubmirror
/
Leaflet
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
build/version.js
21 строка
807 B
Florian Bischof
Set `version` in Leaflet.js when `npm version` is called (#9717)
14 май 2025, 19:45
Не верифицирован
14 май 2025, 19:45
f4eeb7f
Код
Авторство
О чём код?
import {readFileSync, writeFileSync} from 'node:fs'; // TODO: Replace this with a regular import when ESLint adds support for import assertions. // See: https://rollupjs.org/guide/en/#importing-packagejson const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url))); const fileContent = readFileSync(new URL('../src/Leaflet.js', import.meta.url), 'utf8'); const newContent = fileContent.replace( /(\/\/ !!! NEXT LINE IS AUTO-GENERATED VIA `NPM VERSION` !!!\s+export const version = ')[^']+(')/, `$1${pkg.version}$2` ); if (newContent === fileContent) { console.error('Version replacement failed: pattern in Leaflet.js not found.'); process.exit(1); } writeFileSync(new URL('../src/Leaflet.js', import.meta.url), newContent); console.log(`Version updated to ${pkg.version}`);