Skip to content

Commit 42a9c8d

Browse files
chore: remove TODOs in forceignore
1 parent 5e08eb4 commit 42a9c8d

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

src/convert/replacements.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ export const replacementIterations = async (input: string, replacements: MarkedR
6666
const lifecycleInstance = Lifecycle.getInstance();
6767
let output = input;
6868
for (const replacement of replacements) {
69-
// TODO: node 16+ has String.replaceAll for non-regex scenarios
70-
const regex =
71-
typeof replacement.toReplace === 'string' ? new RegExp(replacement.toReplace, 'g') : replacement.toReplace;
72-
const replaced = output.replace(regex, replacement.replaceWith ?? '');
69+
const replaced = output.replaceAll(new RegExp(replacement.toReplace, 'g'), replacement.replaceWith ?? '');
7370

7471
if (replaced !== output) {
7572
output = replaced;

src/resolve/forceIgnore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { dirname, join, relative } from 'node:path';
99
import ignore, { Ignore } from 'ignore/index';
1010
import { readFileSync } from 'graceful-fs';
11-
import { Lifecycle } from '@salesforce/core';
11+
import { Lifecycle, Logger } from '@salesforce/core';
1212
import { SourcePath } from '../common/types';
1313
import { searchUp } from '../utils/fileSystemHandler';
1414

@@ -42,7 +42,7 @@ export class ForceIgnore {
4242
this.forceIgnoreDirectory = dirname(forceIgnorePath);
4343
}
4444
} catch (e) {
45-
// TODO: log no force ignore
45+
Logger.childFromRoot(this.constructor.name).info('no .forceignore found');
4646
}
4747
}
4848

test/resolve/forceIgnore.test.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,30 +84,15 @@ describe('ForceIgnore', () => {
8484
forceIgnore = new ForceIgnore();
8585
});
8686

87-
it('Should ignore files starting with a dot', () => {
88-
const dotPath = join(root, '.xyz');
89-
90-
expect(forceIgnore.accepts(dotPath)).to.be.false;
91-
expect(forceIgnore.denies(dotPath)).to.be.true;
92-
});
93-
94-
it('Should ignore files ending in .dup', () => {
95-
const dupPath = join(root, 'abc.dup');
96-
97-
expect(forceIgnore.accepts(dupPath)).to.be.false;
98-
expect(forceIgnore.denies(dupPath)).to.be.true;
99-
});
100-
101-
it('Should ignore files named package2-descriptor.json', () => {
102-
const descriptorPath = join(root, 'package2-descriptor.json');
103-
expect(forceIgnore.accepts(descriptorPath)).to.be.false;
104-
expect(forceIgnore.denies(descriptorPath)).to.be.true;
105-
});
106-
107-
it('Should ignore files named package2-manifest.json', () => {
108-
const manifestPath = join(root, 'package2-manifest.json');
109-
expect(forceIgnore.accepts(manifestPath)).to.be.false;
110-
expect(forceIgnore.denies(manifestPath)).to.be.true;
87+
// the example's index here is specific to the rules order in ForceIgnore.DEFAULT_IGNORE
88+
const forceIgnoreExamples = ['abc.dup', '.xyz', 'package2-descriptor.json', 'package2-manifest.json'];
89+
forceIgnoreExamples.map((ignore) => {
90+
it(`Should ignore files starting with a ${ignore}`, () => {
91+
const testPath = join(root, ignore);
92+
93+
expect(forceIgnore.accepts(testPath)).to.be.false;
94+
expect(forceIgnore.denies(testPath)).to.be.true;
95+
});
11196
});
11297

11398
it('Should allow .forceignore file to override defaults', () => {

0 commit comments

Comments
 (0)