mem-fs-editor icon indicating copy to clipboard operation
mem-fs-editor copied to clipboard

Unable to copy file using 'memoryFs.copyTpl'

Open Zarmeena opened this issue 1 year ago • 4 comments

Initially the code was working fine, but after moving to async/await, it's not generating the file at target location and no exception is thrown. Following is the code:

import { create as createMemFs } from 'mem-fs'; import { create as createEditor } from 'mem-fs-editor' var store = createMemFs(); var memoryFs = createEditor(store);

memoryFs.copyTpl(templatePath, targetPath, { arr1:val1, arr2:val2, arr3:val3 })

await memoryFs.commit()

Please let me know, if the code has to be corrected or any other solution to get this working

Zarmeena avatar Nov 10 '23 07:11 Zarmeena

Hey @Zarmeena, does a simple memoryFs.write('file.txt', 'content') work?

SBoudrias avatar Nov 10 '23 23:11 SBoudrias

Hey @Zarmeena, does a simple memoryFs.write('file.txt', 'content') work?

Yes @SBoudrias it is working.

Zarmeena avatar Nov 14 '23 06:11 Zarmeena

Initially the code was working fine, but after moving to async/await, it's not generating the file at target location and no exception is thrown. Following is the code:

import { create as createMemFs } from 'mem-fs'; import { create as createEditor } from 'mem-fs-editor' var store = createMemFs(); var memoryFs = createEditor(store);

memoryFs.copyTpl(templatePath, targetPath, { arr1:val1, arr2:val2, arr3:val3 })

await memoryFs.commit()

Please let me know, if the code has to be corrected or any other solution to get this working

While using the above code, it's throwing exception that 'targetPath' is not a directory. Does it have to be the directory path and not the full file path? If yes, how do I pass the file name to be created?

Zarmeena avatar Nov 14 '23 14:11 Zarmeena

@Zarmeena please post a full reproduction steps. Like creating a template, committing and copying the template.

copyTpl supports file, glob, or array as source. If a glob or array is detected (can be a false positive) then a folder is expected to be passed as destination. If a single file is passed, the destination file should be passed.

Without a full reproduction is not possible for us to help.

mshima avatar Nov 14 '23 15:11 mshima