Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: .idea/modules.xml should always uses / instead of \ #582

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));
Salakar marked this conversation as resolved.
Show resolved Hide resolved
},
);
}
Loading