make forward slash in output path consistent

This commit is contained in:
jmbeach
2022-02-02 14:59:58 -05:00
parent 52e971f615
commit 891dbce95c
3 changed files with 24 additions and 0 deletions
+6
View File
@@ -61,6 +61,12 @@ export class ObfuscatedCodeFileUtils {
if (isDirectoryRawInputPath) {
if (isDirectoryRawOutputPath) {
const parsedNormalizedFilePath: path.ParsedPath = path.parse(normalizedFilePath);
// Make ending with "/" consistent
if (!parsedNormalizedFilePath.dir.endsWith('/') && this.inputPath.endsWith('/')) {
parsedNormalizedFilePath.dir += '/';
}
const baseOutputPath: string = path.join(
parsedNormalizedFilePath.dir.replace(this.inputPath, ''),
parsedNormalizedFilePath.base
+1
View File
@@ -48,6 +48,7 @@ import './unit-tests/utils/CryptUtilsStringArray.spec';
import './unit-tests/utils/EscapeSequenceEncoder.spec';
import './unit-tests/utils/LevelledTopologicalSorter.spec';
import './unit-tests/utils/NumberUtils.spec';
import './unit-tests/utils/ObfuscatedCodeFileUtils.spec'
import './unit-tests/utils/RandomGenerator.spec';
import './unit-tests/utils/StringUtils.spec';
import './unit-tests/utils/Utils.spec';
@@ -0,0 +1,17 @@
import { expect } from 'chai';
import { ObfuscatedCodeFileUtils } from '../../../src/cli/utils/ObfuscatedCodeFileUtils';
describe('ObfuscatedCodeFileUtils', () => {
let util: ObfuscatedCodeFileUtils;
beforeEach(() => {
util = new ObfuscatedCodeFileUtils('src/cli/', {
output: 'src/cli/dist',
});
});
it('should handle input path ending (or not ending) with forward slash', () => {
const result = util.getOutputCodePath('src/cli/app.js');
expect(result).equals('src/cli/dist/app.js');
});
});