Skip to content

Commit

Permalink
fix index function to handle options passed
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineKM committed Mar 18, 2024
1 parent 9478b8a commit 9467e82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-terms-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"google-indexing-script": patch
---

Fix index function to handle options passed
17 changes: 10 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ export type IndexOptions = {
path?: string;
};

export const index = async (
input: string = process.argv[2],
options: IndexOptions = {},
) => {
export const index = async (input: string = process.argv[2], options: IndexOptions = {}) => {
if (!input) {
console.error("❌ Please provide a domain or site URL as the first argument.");
console.error("");
process.exit(1);
}

const args = parseCommandLineArgs(process.argv.slice(2));
options.client_email = args['client-email'] || process.env.GIS_CLIENT_EMAIL;
options.private_key = args['private-key'] || process.env.GIS_PRIVATE_KEY;
options.path = args['path'] || process.env.GIS_PATH;
if (!options.client_email) {
options.client_email = args["client-email"] || process.env.GIS_CLIENT_EMAIL;
}
if (!options.private_key) {
options.private_key = args["private-key"] || process.env.GIS_PRIVATE_KEY;
}
if (!options.path) {
options.path = args["path"] || process.env.GIS_PATH;
}

const accessToken = await getAccessToken(options.client_email, options.private_key, options.path);
const siteUrl = convertToSiteUrl(input);
Expand Down

0 comments on commit 9467e82

Please sign in to comment.