Skip to content

Commit

Permalink
fix: fix github-corners config priority. #90
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 30, 2024
1 parent fd58104 commit 63a9786
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
12 changes: 3 additions & 9 deletions packages/action/dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -167599,6 +167599,7 @@ function utils_formatConfig(opts) {
var projectPkg = external_path_.resolve(process.cwd(), opts.config || 'package.json');
var pgkData = {};
if (fs_extra_lib.existsSync(projectPkg)) {
var _options$document$tit, _ref, _opts$githubCorners;
pgkData = fs_extra_lib.readJSONSync(projectPkg);
if (pgkData['markdown-to-html']) {
var mth = pgkData['markdown-to-html'];
Expand All @@ -167613,19 +167614,12 @@ function utils_formatConfig(opts) {
link: link
}, mth.document)
});
if (mth['github-corners']) {
options['github-corners'] = mth['github-corners'];
}
} else {
options.reurls = _objectSpread2(_objectSpread2({}, options.reurls), pgkData.reurls);
options.document = _objectSpread2(_objectSpread2({}, options.document), pgkData.document);
}
if (pgkData.name && !options.document.title) {
options.document.title = pgkData.name;
}
if (pgkData.repository && !opts['github-corners']) {
options['github-corners'] = typeof pgkData.repository === 'string' ? pgkData.repository : pgkData.repository.url;
}
options.document.title = (_options$document$tit = options.document.title) !== null && _options$document$tit !== void 0 ? _options$document$tit : pgkData.name;
options['github-corners'] = (_ref = (_opts$githubCorners = opts['github-corners']) !== null && _opts$githubCorners !== void 0 ? _opts$githubCorners : options['github-corners']) !== null && _ref !== void 0 ? _ref : typeof pgkData.repository === 'string' ? pgkData.repository : pgkData.repository.url;
}
if (opts['github-corners'] && typeof opts['github-corners'] === 'string') {
options['github-corners'] = opts['github-corners'].replace(/^git[+]/, '');
Expand Down
12 changes: 2 additions & 10 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,16 @@ export function formatConfig(opts: Options) {
let pgkData: any = {};
if (fs.existsSync(projectPkg)) {
pgkData = fs.readJSONSync(projectPkg);

if (pgkData['markdown-to-html']) {
const mth = pgkData['markdown-to-html'] as MDToHTMLOptions;
const { title, meta, link } = options.document;
options = { ...options, ...mth, document: { ...options.document, title, meta, link, ...mth.document } }
if (mth['github-corners']) {
options['github-corners'] = mth['github-corners'];
}
} else {
options.reurls = { ...options.reurls, ...pgkData.reurls }
options.document = { ...options.document, ...pgkData.document }
}
if (pgkData.name && !options.document.title) {
options.document.title = pgkData.name;
}
if (pgkData.repository && !opts['github-corners']) {
options['github-corners'] = typeof pgkData.repository === 'string' ? pgkData.repository : pgkData.repository.url;
}
options.document.title = options.document.title ?? pgkData.name;
options['github-corners'] = opts['github-corners'] ?? options['github-corners'] ?? (typeof pgkData.repository === 'string' ? pgkData.repository : pgkData.repository.url);
}
if (opts['github-corners'] && typeof opts['github-corners'] === 'string') {
options['github-corners'] = opts['github-corners'].replace(/^git[+]/, '')
Expand Down

0 comments on commit 63a9786

Please sign in to comment.