constrain method
Implementation
bool constrain(
String path, {
bool includeDevDependencies = false,
VersionBump bump = VersionBump.breaking,
bool dryRun = false,
Iterable<String> packages = const [],
bool pin = false,
}) {
final file = fs.file(path);
if (!file.existsSync()) {
return false;
}
final content = file.readAsStringSync();
final result = applyConstraintsTo(
content,
bump: bump,
packages: packages,
pin: pin,
additionalKeys: [
if (includeDevDependencies) 'dev_dependencies',
],
);
if (result == null) {
return false;
}
if (dryRun) {
return true;
}
file.writeAsStringSync(result);
return true;
}