I am currently building vscode extension for multiple platform (extension include jre) who do I pass extension name while building vscode extension.
extension name got overridden with package.json name.
build.gradle
task buildLinuxExtension(type: NpxTask) {
description "Build the vsix extension package"
dependsOn compileLinuxExtension
command = 'cd'
args = ['LinuxExtension']
command = 'vsce'
args = ['package']
}
``
CodePudding user response:
Before calling vsce
to generate the extension package, you can call a command like sed
to replace "name": "test",
with "name": "LinuxExtension",
in package.json
, if that's what you wanted.
With search engines you can find decades of knowledge around sed
or similar command line tools.
CodePudding user response:
We can parse package.json in build.gradle and set name.
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def void setExtensionName(String extensionName){
def packageSlurper = new JsonSlurper()
def packageJson = packageSlurper.parse file('package.json')
packageJson.name = extensionName
def json_str = JsonOutput.toJson(packageJson)
def json_beauty = JsonOutput.prettyPrint(json_str)
File file = new File("package.json")
file.write(json_beauty)
}