Skip to content

Commit 2591ab7

Browse files
fix: Support numbers as pre release (#943)
Fixes #940 ## Description <!--- Describe your changes in detail --> ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ `feat` -- New feature (non-breaking change which adds functionality) - [x] 🛠️ `fix` -- Bug fix (non-breaking change which fixes an issue) - [ ] ❌ `!` -- Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 `refactor` -- Code refactor - [ ] ✅ `ci` -- Build configuration change - [ ] 📝 `docs` -- Documentation - [ ] 🗑️ `chore` -- Chore
1 parent ddd19ae commit 2591ab7

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

packages/melos/lib/src/commands/publish.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ mixin _PublishMixin on _ExecMixin {
150150
// prerelease version with a matching preid instead if any.
151151
if (package.version.isPreRelease) {
152152
final preid = package.version.preRelease.length == 4
153-
? package.version.preRelease[2] as String
154-
: package.version.preRelease[0] as String;
153+
? package.version.preRelease[2].toString()
154+
: package.version.preRelease[0].toString();
155155
final versionsWithPreid = versions
156156
.where((version) => version.contains(preid))
157157
.toList();

packages/melos/test/commands/publish_test.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,38 @@ void main() {
120120
});
121121
}
122122
});
123+
124+
test('should support number as pre release version', () async {
125+
final logger = TestLogger();
126+
final workspaceDir = await createTemporaryWorkspace(
127+
configBuilder: (path) => MelosWorkspaceConfig(
128+
path: path,
129+
name: 'test_workspace',
130+
packages: [
131+
createGlob('packages/**', currentDirectoryPath: path),
132+
],
133+
),
134+
135+
workspacePackages: const ['a'],
136+
);
137+
138+
await createProject(
139+
workspaceDir,
140+
Pubspec('a', version: Version(1, 2, 3, pre: '4')),
141+
);
142+
143+
final config = await MelosWorkspaceConfig.fromWorkspaceRoot(
144+
workspaceDir,
145+
);
146+
final melos = Melos(
147+
config: config,
148+
logger: logger,
149+
);
150+
151+
await expectLater(melos.publish(force: true), completes);
152+
final output = logger.output.normalizeLines().split('\n');
153+
expect(output, contains('Publishing a 1.2.3-4 to https://pub.dev:'));
154+
});
123155
});
124156
}
125157

0 commit comments

Comments
 (0)