DartBuild constructor
DartBuild({})
Implementation
DartBuild({
String? appName,
required this.mainPath,
String? appVersion,
String? buildPreRelease,
String? buildMetadata,
this.buildArgs = const [],
String? releaseFolder,
List<String>? includedPaths,
String? buildFolder,
String? executableName,
String? dartSdkPath,
}) : dartSdkPath = dartSdkPath ?? 'dart',
releaseFolder = releaseFolder ?? 'build/releases',
includedPaths = includedPaths ?? [] {
_arch = getCpuArchitecture();
final pubspecStr = File('pubspec.yaml').readAsStringSync();
final pubspec = Pubspec.parse(pubspecStr);
final buildVersion = resolveVersion(
pubspecVersion: pubspec.version,
appVersion: appVersion,
buildVersion: null,
buildPreRelease: buildPreRelease,
buildMetadata: buildMetadata,
);
if (appVersion != null) {
this.appVersion = appVersion;
} else {
this.appVersion = 'v${buildVersion.canonicalizedVersion}';
}
if (appName == null) {
this.appName = pubspec.name;
} else {
this.appName = appName;
}
if (executableName == null) {
String execName = this.appName.replaceAll('_', '-');
if (Platform.isWindows) {
execName += '.exe';
}
this.executableName = execName;
} else {
this.executableName = executableName;
}
if (buildFolder == null) {
this.buildFolder = 'bin';
} else {
this.buildFolder = buildFolder;
}
}