write method

bool write(
  1. AFCommandContext context
)

Implementation

bool write(AFCommandContext context) {
  final output = context.output;
  // make sure the folder exists before we write a file.
  AFProjectPaths.ensureFolderExistsForFile(projectPath);

  final action = _findAction(context);
  final color = (this.action == AFGeneratedFileAction.create) ? Styles.GREEN : Styles.YELLOW;
  output.writeTwoColumns(
    col1: "$action ",
    col2: AFProjectPaths.relativePathFor(projectPath),
    color1: color
  );

  final path = AFProjectPaths.fullPathFor(this.projectPath);

  // fix up any imports, sorting them and removing excess spaces.
  buffer.fixupImports(path);

  final f = File(path);
  f.writeAsStringSync(buffer.toString());
  return true;
}