installDependencies function
Installs project dependencies using 'dart pub get'.
Implementation
Future<void> installDependencies(
String projectName,
Progress progressLogger,
) async {
final installResult = await Process.run(
'dart',
['pub', 'get'],
workingDirectory: projectName,
runInShell: true,
);
if (installResult.exitCode != 0) {
progressLogger.fail('Failed to install dependencies.');
// Proporcionar información más útil en caso de fallo
logger.err(
'Failed to fetch dependencies (exit code ${installResult.exitCode}).',
);
logger.info('Stderr: ${installResult.stderr}');
logger.info(
'Please check your network connection or run the following command manually:',
);
logger.write(' \$ cd $projectName && dart pub get\n');
exit(1);
}
}