Skip to content

Commit

Permalink
fix: modify readOrgList function
Browse files Browse the repository at this point in the history
  • Loading branch information
btrn11 committed Jan 14, 2025
1 parent 94571a9 commit 2089364
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/commands/package/pushupgrade/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import fs from 'node:fs/promises';
import * as csv from 'csv-parse/sync';
import { Flags, SfCommand, orgApiVersionFlagWithDeprecations } from '@salesforce/sf-plugins-core';
import { Messages, SfError } from '@salesforce/core';
import { PackagePushScheduleResult, PackagePushUpgrade } from '@salesforce/packaging';
Expand Down Expand Up @@ -76,13 +75,13 @@ function isValidPackageVersionId(id: string): boolean {
async function readOrgListFile(filePath: string): Promise<string[]> {
try {
const fileContent = await fs.readFile(filePath, 'utf-8');
const records = csv.parse(fileContent, { columns: false, skipEmptyLines: true }) as string[][];
const orgIds = fileContent.split(/\s+/).filter((id) => id.length > 0);

if (records.length === 0) {
if (orgIds.length === 0) {
throw new SfError(messages.getMessage('error.empty-org-list'));
}

return records.map((row: string[]) => row[0]).filter((id: string) => /^00D[a-zA-Z0-9]{15}$/.test(id));
return orgIds.filter((id: string) => /^00D[a-zA-Z0-9]{12}$/.test(id));
} catch (error) {
throw new SfError(messages.getMessage('error.invalid-org-list-file'));
}
Expand Down

0 comments on commit 2089364

Please sign in to comment.