/
githubmirror
/
docusaurus
Обзор
Документация
Войти
/
githubmirror
/
docusaurus
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/docusaurus-theme-common/removeThemeInternalReexport.mjs
32 строки
948 B
Sébastien Lorber
refactor(theme-common): split package into public/internal API entrypoints (#7660)
24 июн 2022, 12:21
Не верифицирован
24 июн 2022, 12:21
9473508
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import fs from 'fs-extra'; // See comment in src/internal.ts // This script should be run by CI tests to remove: // export * from './index' const filePath = 'lib/internal.js'; const lineToRemove = "export * from './index';\n"; if (!(await fs.pathExists(filePath))) { throw new Error(`internal entrypoint file not found at ${filePath}`); } const fileContent = await fs.readFile(filePath, 'utf8'); const fileContentUpdated = fileContent.replaceAll(lineToRemove, ''); // Ensure the script correctly removes the re-export if (fileContent === fileContentUpdated) { throw new Error( 'Unexpected: internal re-export has not been replaced.\nMake sure this script works, and is only run once.', ); } await fs.writeFile(filePath, fileContentUpdated);