mem-fs-editor
mem-fs-editor copied to clipboard
Unable to copy file using 'memoryFs.copyTpl'
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
Hey @Zarmeena, does a simple memoryFs.write('file.txt', 'content')
work?
Hey @Zarmeena, does a simple
memoryFs.write('file.txt', 'content')
work?
Yes @SBoudrias it is working.
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 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.