Skip to content

Commit 19198f4

Browse files
committed
Set script-runner config
1 parent cb8743f commit 19198f4

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

apps/remix-ide/src/app/plugins/script-runner-bridge.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const profile = {
2222
maintainedBy: 'Remix',
2323
}
2424

25-
const configFileName = '.remix/script.config.json'
25+
const oldConfigFileName = '.remix/script.config.json'
26+
const configFileName = 'remix.config.json'
2627

2728
let baseUrl = 'https://remix-project-org.github.io/script-runner-generator'
2829
const customBuildUrl = 'http://localhost:4000/build' // this will be used when the server is ready
@@ -259,7 +260,7 @@ export class ScriptRunnerBridgePlugin extends Plugin {
259260
try {
260261
const content = await this.plugin.call('fileManager', 'readFile', configFileName)
261262
const parsed = JSON.parse(content)
262-
this.customConfig = parsed
263+
this.customConfig = parsed['script-runner']
263264
} catch (e) {
264265
this.customConfig = {
265266
defaultConfig: 'default',
@@ -274,7 +275,7 @@ export class ScriptRunnerBridgePlugin extends Plugin {
274275
async openCustomConfig() {
275276

276277
try {
277-
await this.plugin.call('fileManager', 'open', '.remix/script.config.json')
278+
await this.plugin.call('fileManager', 'open', 'remix.config.json')
278279
} catch (e) {}
279280
}
280281

@@ -297,16 +298,19 @@ export class ScriptRunnerBridgePlugin extends Plugin {
297298
}
298299

299300
async saveCustomConfig(content: ScriptRunnerConfig) {
300-
if (content.customConfig.dependencies.length === 0 && content.defaultConfig === 'default') {
301-
try {
302-
const exists = await this.plugin.call('fileManager', 'exists', '.remix/script.config.json')
303-
if (exists) {
304-
await this.plugin.call('fileManager', 'remove', '.remix/script.config.json')
305-
}
306-
} catch (e) {}
307-
return
308-
}
309-
await this.plugin.call('fileManager', 'writeFile', '.remix/script.config.json', JSON.stringify(content, null, 2))
301+
try {
302+
const exists = await this.plugin.call('fileManager', 'exists', 'remix.config.json')
303+
if (exists) {
304+
const configContent = await this.plugin.call('fileManager', 'readFile', 'remix.config.json')
305+
const config = JSON.parse(configContent)
306+
307+
config['script-runner'] = content
308+
await this.plugin.call('fileManager', 'writeFile', 'remix.config.json', JSON.stringify(config, null, 2))
309+
} else {
310+
await this.plugin.call('fileManager', 'writeFile', 'remix.config.json', JSON.stringify({ 'script-runner': content }, null, 2))
311+
}
312+
} catch (e) {}
313+
return
310314
}
311315

312316
async activateCustomScriptRunner(config: customScriptRunnerConfig) {
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"defaultConfig": "ethers6",
3-
"customConfig": {
4-
"baseConfiguration": "default",
5-
"dependencies": []
2+
"script-runner": {
3+
"defaultConfig": "ethers6",
4+
"customConfig": {
5+
"baseConfiguration": "default",
6+
"dependencies": []
7+
}
68
}
79
}

0 commit comments

Comments
 (0)