setPubspecReadOnly function
Sets the pubspec.yaml file as read-only.
The function takes in the projectName
and the pubspec
content to write into the file.
After writing the content, it attempts to make the file read-only.
Prints success or failure message based on the outcome.
Implementation
void setPubspecReadOnly(String projectName, String pubspec) {
final pubspecFile = File('$projectName/pubspec.yaml');
pubspecFile.writeAsStringSync(pubspec);
if (makeReadOnly(pubspecFile.path)) {
print('pubspec.yaml now read-only.');
} else {
print('Failed to make pubspec.yaml read-only.');
}
}