@@ -120,8 +120,6 @@ export const doExport = async (uri: Uri, document: TextDocument) => {
120
120
const input = await createWorkFile ( document )
121
121
122
122
try {
123
- let output = { path : uri . fsPath , isTmp : false }
124
-
125
123
const ouputExt = path . extname ( uri . path )
126
124
const outputToLocalFS = uri . scheme === 'file'
127
125
@@ -131,16 +129,16 @@ export const doExport = async (uri: Uri, document: TextDocument) => {
131
129
throw new Error ( `Could not write to ${ uri . scheme } file system.` )
132
130
}
133
131
134
- if ( ! outputToLocalFS ) {
135
- // Marp CLI cannot write the output directly to the path that has a
136
- // virtual scheme. So export to a temporary file and after copy it to
137
- // the actual path by using VS Code API if the output path has not a
138
- // scheme of the local file system.
139
- output = {
140
- path : path . join ( tmpdir ( ) , `marp-vscode-tmp- ${ nanoid ( ) } ${ ouputExt } ` ) ,
141
- isTmp : true ,
142
- }
143
- }
132
+ // Marp CLI cannot write the output directly to the path that has a
133
+ // virtual scheme. So export to a temporary file and after copy it to the
134
+ // actual path by using VS Code API if the output path has not a scheme of
135
+ // the local file system.
136
+ const cliOutput = outputToLocalFS
137
+ ? { path : uri . fsPath , isTmp : false }
138
+ : {
139
+ path : path . join ( tmpdir ( ) , `marp-vscode-tmp- ${ nanoid ( ) } ${ ouputExt } ` ) ,
140
+ isTmp : true ,
141
+ }
144
142
145
143
const pptxEditableSmart =
146
144
ouputExt === '.pptx' &&
@@ -161,7 +159,7 @@ export const doExport = async (uri: Uri, document: TextDocument) => {
161
159
162
160
try {
163
161
await marpCli (
164
- [ '-c' , conf . path , input . path , '-o' , output . path ] ,
162
+ [ '-c' , conf . path , input . path , '-o' , cliOutput . path ] ,
165
163
{ baseUrl } ,
166
164
{
167
165
onCLIError : ( { error, codes } ) => {
@@ -225,8 +223,8 @@ export const doExport = async (uri: Uri, document: TextDocument) => {
225
223
226
224
// If the output has been created in the temporary directory, we should
227
225
// copy it to the actual path and remove the tmpfile.
228
- if ( output . isTmp ) {
229
- const outputUri = Uri . file ( output . path )
226
+ if ( cliOutput . isTmp ) {
227
+ const outputUri = Uri . file ( cliOutput . path )
230
228
231
229
try {
232
230
await workspace . fs . copy ( outputUri , uri , { overwrite : true } )
0 commit comments