diff --git a/docs/configuration/overview.mdx b/docs/configuration/overview.mdx index 32f1bb916..b1aece321 100644 --- a/docs/configuration/overview.mdx +++ b/docs/configuration/overview.mdx @@ -119,6 +119,19 @@ collisions with other IntelliJ modules you may already have in place. The default is 'melos\_'. +### executeInTerminal + +Whether to execute the script in a terminal. + +The default is `true`. + +```yaml +melos: + ide: + intellij: + executeInTerminal: false +``` + ## scripts Define custom scripts that can be executed in the workspace via the diff --git a/packages/melos/lib/src/common/intellij_project.dart b/packages/melos/lib/src/common/intellij_project.dart index dd252a20a..36700399e 100644 --- a/packages/melos/lib/src/common/intellij_project.dart +++ b/packages/melos/lib/src/common/intellij_project.dart @@ -143,8 +143,8 @@ class IntellijProject { 'fileurl="file://\$PROJECT_DIR\$/$imlPath" ' 'filepath="\$PROJECT_DIR\$/$imlPath" ' '/>'; - // Pad to preserve formatting on generated file. Indent x6. - return ' $module'; + // Pad to preserve formatting on generated file. + return module.padLeft(6); } Future forceWriteToFile(String filePath, String fileContents) async { @@ -265,6 +265,8 @@ class IntellijProject { 'scriptName': scriptName, 'scriptArgs': scriptArgs, 'scriptPath': getMelosBinForIde(), + 'executeInTerminal': + _workspace.config.ide.intelliJ.executeInTerminal.toString(), }); final outputFile = p.join( diff --git a/packages/melos/lib/src/workspace_config.dart b/packages/melos/lib/src/workspace_config.dart index e3a7de1cb..f41d5c724 100644 --- a/packages/melos/lib/src/workspace_config.dart +++ b/packages/melos/lib/src/workspace_config.dart @@ -65,6 +65,7 @@ class IntelliJConfig { const IntelliJConfig({ this.enabled = _defaultEnabled, this.moduleNamePrefix = _defaultModuleNamePrefix, + this.executeInTerminal = _defaultExecuteInTerminal, }); factory IntelliJConfig.fromYaml(Object? yaml) { @@ -79,9 +80,17 @@ class IntelliJConfig { final enabled = yaml.containsKey('enabled') ? assertKeyIsA(key: 'enabled', map: yaml, path: 'ide/intellij') : _defaultEnabled; + final executeInTerminal = yaml.containsKey('executeInTerminal') + ? assertKeyIsA( + key: 'executeInTerminal', + map: yaml, + path: 'ide/intellij', + ) + : _defaultExecuteInTerminal; return IntelliJConfig( enabled: enabled, moduleNamePrefix: moduleNamePrefix, + executeInTerminal: executeInTerminal, ); } else { final enabled = assertIsA( @@ -96,15 +105,19 @@ class IntelliJConfig { static const empty = IntelliJConfig(); static const _defaultModuleNamePrefix = 'melos_'; static const _defaultEnabled = true; + static const _defaultExecuteInTerminal = true; final bool enabled; final String moduleNamePrefix; + final bool executeInTerminal; + Object? toJson() { return { 'enabled': enabled, 'moduleNamePrefix': moduleNamePrefix, + 'executeInTerminal': executeInTerminal, }; } @@ -113,11 +126,15 @@ class IntelliJConfig { other is IntelliJConfig && runtimeType == other.runtimeType && other.enabled == enabled && - other.moduleNamePrefix == moduleNamePrefix; + other.moduleNamePrefix == moduleNamePrefix && + other.executeInTerminal == executeInTerminal; @override int get hashCode => - runtimeType.hashCode ^ enabled.hashCode ^ moduleNamePrefix.hashCode; + runtimeType.hashCode ^ + enabled.hashCode ^ + moduleNamePrefix.hashCode ^ + executeInTerminal.hashCode; @override String toString() { @@ -125,6 +142,7 @@ class IntelliJConfig { IntelliJConfig( enabled: $enabled, moduleNamePrefix: $moduleNamePrefix, + executeInTerminal: $executeInTerminal, ) '''; } diff --git a/packages/melos/templates/intellij/runConfigurations/shell_script.xml.tmpl b/packages/melos/templates/intellij/runConfigurations/shell_script.xml.tmpl index 095fd6e38..b1498f1f5 100644 --- a/packages/melos/templates/intellij/runConfigurations/shell_script.xml.tmpl +++ b/packages/melos/templates/intellij/runConfigurations/shell_script.xml.tmpl @@ -6,6 +6,7 @@