call static method
Implementation
static Future<bool> call(
DesignPattern designPattern,
) async {
var path = _replaceWordsInFile(
designPattern.path(),
);
var nameFile = _replaceWordsInFile(
designPattern.nameFile(),
);
var templete = _replaceWordsInFile(
designPattern.template(),
);
var extension = designPattern.extension();
var completePath = p.normalize(
'${GlobalVariable.path}/$path/$nameFile.$extension',
);
if (!designPattern.generate()) {
warn('Para gerar o arquivo: "$nameFile.$extension" altera em .ft_cli/config a variavel "generate"');
return true;
}
await DirectoryUtils.create(
p.normalize('${GlobalVariable.path}/$path'),
);
if (File(completePath).existsSync()) {
error('Arquivo já existe: $nameFile.$extension....');
throw FileExistsError(innerException: Exception());
}
warn('Gerando $nameFile.$extension....');
File(completePath).writeAsStringSync(templete);
warn('Arquivo criado $completePath....');
await applyTriggersIfNecessary(designPattern);
return true;
}