Skip to content

Commit

Permalink
fix: add debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed May 12, 2023
1 parent f783f77 commit d662ce5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/commands/infuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,11 @@ function removeItem<T> (item: T, items: T[]): boolean {

function apply (messages: LocaleMessages, meta: MetaLocaleMessage): MetaLocaleMessage {
const { target, components } = meta
debug(`apply meta.target = ${target}`)

for (const [component, blocks] of Object.entries(components)) {
debug(`apply component = ${component}, blocks = ${JSON.stringify(blocks)}`)
const { hierarchy } = parsePath(target, component)
debug(`apply component = ${component}, hierarchy = ${hierarchy}, blocks = ${JSON.stringify(blocks)}`)

const collectMessages = getTargetLocaleMessages(messages, hierarchy)
VERBOSE && debug('collect messages', JSON.stringify(collectMessages, null, 2))
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ export function reflectSFCDescriptor (basePath: string, components: SFCFileInfo[

export function parsePath (basePath: string, targetPath: string) {
const { dir, name } = path.parse(targetPath)
debug(`parsePath: dir = ${dir}, name = ${name}`)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, target] = dir.split(basePath)
debug(`parsePath: 1st splited _ = ${_}, target = ${target}`)
const parsedTargetPath = target.split(path.sep)
debug(`parsePath: 2nd splited parsedTargetPath = ${parsedTargetPath}`)
parsedTargetPath.shift()
debug(`parsePath: contentPath = ${targetPath}, component = ${name}, messageHierarchy = ${parsedTargetPath}`)
return {
Expand Down

0 comments on commit d662ce5

Please sign in to comment.