Skip to content

Commit

Permalink
refactor: remove non necessary treatPathSep
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon committed Nov 7, 2024
1 parent 8354c77 commit c87f656
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/adapter/GitAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const TREE_TYPE = 'tree'
const NUM_STAT_REGEX = /^((\d+|\-)\t){2}/
const EOL = new RegExp(/\r?\n/)

const revPath = (pathDef: FileGitRef) =>
`${pathDef.oid}:${treatPathSep(pathDef.path)}`
const revPath = (pathDef: FileGitRef) => `${pathDef.oid}:${pathDef.path}`

export default class GitAdapter {
private static instances: Map<Config, GitAdapter> = new Map()
Expand Down Expand Up @@ -89,7 +88,7 @@ export default class GitAdapter {
'--name-only',
'-r',
this.config.to,
treatPathSep(path),
path,
])
)
.split(EOL)
Expand Down
4 changes: 2 additions & 2 deletions src/post-processor/flowTranslationProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { MetadataRepository } from '../metadata/MetadataRepository'
import type { Work } from '../types/work'
import { readDir, writeFile } from '../utils/fsHelper'
import { isSamePath, isSubDir, readFile, treatPathSep } from '../utils/fsUtils'
import { isSamePath, isSubDir, readFile } from '../utils/fsUtils'
import {
asArray,
convertJsonToXml,
Expand Down Expand Up @@ -164,7 +164,7 @@ export default class FlowTranslationProcessor extends BaseProcessor {
protected async _getTranslationAsJSON(translationPath: string) {
const translationPathInOutputFolder = join(
this.config.output,
treatPathSep(translationPath)
translationPath
)
const translationExist = await pathExists(translationPathInOutputFolder)

Expand Down
3 changes: 1 addition & 2 deletions src/post-processor/includeProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { MetadataRepository } from '../metadata/MetadataRepository'
import DiffLineInterpreter from '../service/diffLineInterpreter'
import type { Work } from '../types/work'
import { TAB } from '../utils/cliConstants'
import { treatPathSep } from '../utils/fsUtils'
import { IgnoreHelper, buildIncludeHelper } from '../utils/ignoreHelper'

import BaseProcessor from './baseProcessor'
Expand Down Expand Up @@ -52,7 +51,7 @@ export default class IncludeProcessor extends BaseProcessor {
)
for (const line of lines) {
Object.keys(includeHolder).forEach(changeType => {
const changedLine = `${changeType}${TAB}${treatPathSep(line)}`
const changedLine = `${changeType}${TAB}${line}`
if (!this.includeHelper.keep(changedLine)) {
includeHolder[changeType as keyof typeof includeHolder].push(
changedLine
Expand Down
5 changes: 2 additions & 3 deletions src/utils/fsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import GitAdapter from '../adapter/GitAdapter'
import type { Config } from '../types/config'
import type { FileGitRef } from '../types/git'

import { treatPathSep } from './fsUtils'
import { buildIgnoreHelper } from './ignoreHelper'

const copiedFiles = new Set()
Expand All @@ -30,7 +29,7 @@ export const copyFiles = async (config: Config, src: string) => {
// Use Buffer to output the file content
// Let fs implementation detect the encoding ("utf8" or "binary")
const dst = join(config.output, file.path)
await outputFile(treatPathSep(dst), file.content)
await outputFile(dst, file.content)
copiedFiles.add(dst)
}
} catch {
Expand Down Expand Up @@ -80,5 +79,5 @@ export const writeFile = async (
if (ignoreHelper.globalIgnore.ignores(path)) {
return
}
await outputFile(join(config.output, treatPathSep(path)), content)
await outputFile(join(config.output, path), content)
}

0 comments on commit c87f656

Please sign in to comment.