From f7fcf55db6969e9c3b5ed048c2d345265e19a061 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 20 Aug 2023 22:56:09 -0400 Subject: [PATCH] fix(bindgen): use writeIfOverrideNotPresent for python function modules --- src/bindgen/python/emscripten/emscripten-function-module.js | 3 ++- src/bindgen/python/wasi/wasi-function-module.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bindgen/python/emscripten/emscripten-function-module.js b/src/bindgen/python/emscripten/emscripten-function-module.js index 1258b2a21..bd2a1a59b 100644 --- a/src/bindgen/python/emscripten/emscripten-function-module.js +++ b/src/bindgen/python/emscripten/emscripten-function-module.js @@ -8,6 +8,7 @@ import functionModuleArgs from '../function-module-args.js' import functionModuleReturnType from '../function-module-return-type.js' import functionModuleDocstring from '../function-module-docstring.js' import interfaceJsonTypeToInterfaceType from '../../interface-json-type-to-interface-type.js' +import writeIfOverrideNotPresent from '../../write-if-override-not-present.js' function emscriptenFunctionModule(interfaceJson, pypackage, modulePath) { const functionName = snakeCase(interfaceJson.name) @@ -99,7 +100,7 @@ ${addKwargs} return output_list[0] return tuple(output_list) ` - fs.writeFileSync(modulePath, moduleContent) + writeIfOverrideNotPresent(modulePath, moduleContent, '#') } export default emscriptenFunctionModule diff --git a/src/bindgen/python/wasi/wasi-function-module.js b/src/bindgen/python/wasi/wasi-function-module.js index 1a4f62f62..73850f2b7 100644 --- a/src/bindgen/python/wasi/wasi-function-module.js +++ b/src/bindgen/python/wasi/wasi-function-module.js @@ -9,6 +9,7 @@ import functionModuleDocstring from '../function-module-docstring.js' import functionModuleArgs from '../function-module-args.js' import interfaceJsonTypeToInterfaceType from '../../interface-json-type-to-interface-type.js' import interfaceJsonTypeToPythonType from '../interface-json-type-to-python-type.js' +import writeIfOverrideNotPresent from '../../write-if-override-not-present.js' function wasiFunctionModule(interfaceJson, pypackage, modulePath) { const functionName = snakeCase(interfaceJson.name) @@ -228,7 +229,7 @@ ${args} ${postOutput} ` - fs.writeFileSync(modulePath, moduleContent) + writeIfOverrideNotPresent(modulePath, moduleContent, '#') } export default wasiFunctionModule