Skip to content

Commit

Permalink
fix: .idea/modules.xml should always uses / instead of \ (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Nov 6, 2023
1 parent 6a64b05 commit 5d49c4a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/melos/lib/src/common/intellij_project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ class IntellijProject {
}

String ideaModuleStringForName(String moduleName, {String? relativePath}) {
final imlPath = relativePath != null
var imlPath = relativePath != null
? p.normalize('$relativePath/$moduleName.iml')
: '$moduleName.iml';
// Use `/` instead of `\` no matter what platform is.
imlPath = imlPath.replaceAll(r'\', '/');
final module = '<module '
'fileurl="file://\$PROJECT_DIR\$/$imlPath" '
'filepath="\$PROJECT_DIR\$/$imlPath" '
Expand Down
25 changes: 25 additions & 0 deletions packages/melos/test/common/intellij_project_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,29 @@ void main() {
expect(modulesXml, contains(r'file://$PROJECT_DIR$/melos_root.iml'));
},
);

// https://github.com/invertase/melos/issues/582
test(
'always generates iml paths with `/`',
() async {
final tempDir = createTestTempDir();
final workspaceBuilder = VirtualWorkspaceBuilder(
path: tempDir.path,
'''
packages:
- .
''',
)..addPackage(
'''
name: test
''',
path: 'test',
);
final workspace = workspaceBuilder.build();
final project = IntellijProject.fromWorkspace(workspace);
await project.generate();
final modulesXml = readTextFile(project.pathModulesXml);
expect(modulesXml, contains(r'file://$PROJECT_DIR$/test/melos_test.iml'));
},
);
}

0 comments on commit 5d49c4a

Please sign in to comment.