Skip to content

Commit

Permalink
feat(config): handle missing config
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomej committed Jan 5, 2025
1 parent f501f72 commit 0350859
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ if (args.help || args.version === '' || args.version === true) {
log(' --debug Debug mode');
log(' ');
process.exit(args.help ? 0 : 1);
} else if (!config.domain && !args.domain) {
} else if (!config?.domain && !args.domain) {
console.log(
`⚠ svelte-sitemap: --domain argument is required.\n\nSee instructions: ${REPO_URL}\n\nExample:\n\n svelte-sitemap --domain https://mydomain.com\n`
);
process.exit(0);
} else if (
// (config.domain || args.domain) &&
!config.domain?.includes('http') &&
!config?.domain?.includes('http') &&
!args.domain?.includes('http')
) {
console.log(
Expand All @@ -87,7 +87,11 @@ if (args.help || args.version === '' || args.version === true) {
} else {
const domain: string = args.domain ? args.domain : undefined;
const debug: boolean = args.debug === '' || args.debug === true ? true : false;
const additional = Array.isArray(args['additional']) ? args['additional'] : args.additional ? [args.additional] : [];
const additional = Array.isArray(args['additional'])
? args['additional']
: args.additional
? [args.additional]
: [];
const resetTime: boolean =
args['reset-time'] === '' || args['reset-time'] === true ? true : false;
const trailingSlashes: boolean =
Expand All @@ -107,7 +111,7 @@ if (args.help || args.version === '' || args.version === true) {
attribution,
ignore,
trailingSlashes,
additional,
additional
};

// Config file is preferred
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svelte-sitemap",
"version": "2.7.0",
"version": "3.0.0-next.8",
"description": "Small helper which scans your Svelte routes folder and generates static sitemap.xml",
"main": "./dist/index.js",
"author": "BART! <[email protected]>",
Expand All @@ -22,8 +22,8 @@
"test:coverage": "vitest run --coverage",
"postinstall": "cp -r ./src/build/ ./build",
"postversion": "git push && git push --follow-tags",
"publish:next": "yarn && yarn build && yarn test && cd dist && npm publish --tag next",
"publish:beta": "yarn && yarn build && yarn test && cd dist && npm publish --tag beta",
"publish:next": "yarn && yarn build && yarn test run && cd dist && npm publish --tag next",
"publish:beta": "yarn && yarn build && yarn test run && cd dist && npm publish --tag beta",
"release:beta": "npm version prerelease -m \"chore(update): prelease %s β\"",
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛 \"",
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { OptionsSvelteSitemap } from '../interfaces/global.interface';
import { OUT_DIR } from './../vars';
import { loadFile } from './file';

export const loadConfig = (path: string): OptionsSvelteSitemap => {
export const loadConfig = (path: string): OptionsSvelteSitemap | undefined => {
const baseConfig = loadFile<OptionsSvelteSitemap>(path);
return baseConfig!;
};
Expand Down

0 comments on commit 0350859

Please sign in to comment.