Skip to content

Commit

Permalink
refactor: no-param-reassign
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Apr 5, 2024
1 parent 686d8fb commit 83d1565
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ export async function executeDeploy(
await deploy.start();
}
} else {
// mdapi format deploys don't require a project, but at this point we need one
project ??= await SfProject.resolve();
// instantiate source tracking
// stl will decide, based on the org's properties, what needs to be done
const stl = await SourceTracking.create({
org,
project,
// mdapi format deploys don't require a project, but at this point we need one
project: project ?? (await SfProject.resolve()),
subscribeSDREvents: true,
ignoreConflicts: opts['ignore-conflicts'],
});
Expand Down
6 changes: 3 additions & 3 deletions src/utils/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ async function ensureDirectoryPath(path: string): Promise<string> {
return resolvedPath;
}

function resolveZipFileName(zipFileName?: string): string {
const resolveZipFileName = (zipFileName?: string): string => {
if (!zipFileName) {
return DEFAULT_ZIP_FILE_NAME;
}
// If no file extension was provided append, '.zip'
return !extname(zipFileName) ? (zipFileName += '.zip') : zipFileName;
}
return !extname(zipFileName) ? `${zipFileName}.zip` : zipFileName;
};

export const DEFAULT_ZIP_FILE_NAME = 'unpackaged.zip';

Expand Down
4 changes: 2 additions & 2 deletions test/nuts/convert/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import { ConvertMdapiJson } from '../../../src/utils/types.js';
let session: TestSession;

const writeManifest = (manifestPath: string, contents?: string) => {
contents ??= `<?xml version="1.0" encoding="UTF-8"?>
const defaultContents = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<version>53.0</version>
</Package>`;
fs.writeFileSync(manifestPath, contents);
fs.writeFileSync(manifestPath, contents ?? defaultContents);
};

describe('project convert mdapi NUTs', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/nuts/convert/source.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import { ConvertResultJson } from '../../../src/utils/types.js';
let session: TestSession;

const writeManifest = (manifestPath: string, contents?: string) => {
contents ??= `<?xml version="1.0" encoding="UTF-8"?>
const defaultContents = `<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<version>53.0</version>
</Package>`;
fs.writeFileSync(manifestPath, contents);
fs.writeFileSync(manifestPath, contents ?? defaultContents);
};

describe('project convert source NUTs', () => {
Expand Down
3 changes: 3 additions & 0 deletions test/nuts/digitalExperienceBundle/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
// existing tests do a lot mutation. I decided to leave rather than refactor
/* eslint-disable no-param-reassign */

import { join, relative } from 'node:path';
import * as fs from 'node:fs';
import { FileResponse } from '@salesforce/source-deploy-retrieve';
Expand Down
9 changes: 4 additions & 5 deletions test/nuts/specialTypes/folderTypes.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ describe('metadata types that go in folders', () => {
];

const getRelativeFileResponses = (resp: FileResponse[]) =>
resp.map((s) => {
// grab the last 2 directories with the file only
s.filePath = s.filePath?.split(path.sep).slice(-3).join(path.sep);
return s;
});
resp.map((fr) => ({
...fr,
filePath: fr.filePath?.split(path.sep).slice(-3).join(path.sep),
}));

it('can generate manifest for just the emailTemplates', () => {
const pathToEmails = path.join('force-app', 'main', 'default', 'email');
Expand Down

0 comments on commit 83d1565

Please sign in to comment.