Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
for more information.
- Remove interactive prompts for whether to delete files.
- Ignore `-d` flag: always delete files as if `-d` was passed.
- Remove `--use-polling-watcher` flag.
- Documentation revamp.

## 2.6.1
Expand Down
36 changes: 15 additions & 21 deletions build_runner/lib/src/daemon/daemon_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,28 +274,22 @@ class BuildRunnerDaemonBuilder implements DaemonBuilder {
);

// Only actually used for the AutoChangeProvider.
Stream<List<WatchEvent>> graphEvents() => PackageGraphWatcher(
packageGraph,
watch:
(node) => PackageNodeWatcher(
node,
watch: daemonOptions.directoryWatcherFactory,
Stream<List<WatchEvent>> graphEvents() =>
PackageGraphWatcher(packageGraph, watch: PackageNodeWatcher.new)
.watch()
.asyncWhere(
(change) => shouldProcess(
change,
buildSeries.assetGraph,
buildOptions,
// Assume we will create an outputDir.
true,
expectedDeletes,
environment.reader,
),
)
.watch()
.asyncWhere(
(change) => shouldProcess(
change,
buildSeries.assetGraph,
buildOptions,
// Assume we will create an outputDir.
true,
expectedDeletes,
environment.reader,
),
)
.map((data) => WatchEvent(data.type, '${data.id}'))
.debounceBuffer(buildOptions.debounceDelay);
)
.map((data) => WatchEvent(data.type, '${data.id}'))
.debounceBuffer(buildOptions.debounceDelay);

var changeProvider =
daemonOptions.buildMode == BuildMode.Auto
Expand Down
17 changes: 0 additions & 17 deletions build_runner/lib/src/entrypoint/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import 'package:build_config/build_config.dart';
import 'package:build_daemon/constants.dart';
import 'package:build_runner_core/build_runner_core.dart';
import 'package:path/path.dart' as p;
import 'package:watcher/watcher.dart';

import '../generate/directory_watcher_factory.dart';

const buildFilterOption = 'build-filter';
const configOption = 'config';
Expand All @@ -31,7 +28,6 @@ const releaseOption = 'release';
const trackPerformanceOption = 'track-performance';
const skipBuildScriptCheckOption = 'skip-build-script-check';
const symlinkOption = 'symlink';
const usePollingWatcherOption = 'use-polling-watcher';
const verboseOption = 'verbose';

enum BuildUpdatesOption { none, liveReload }
Expand Down Expand Up @@ -141,7 +137,6 @@ class DaemonOptions extends WatchOptions {
required super.builderConfigOverrides,
required super.isReleaseBuild,
required super.logPerformanceDir,
required super.usePollingWatcher,
required super.enableExperiments,
}) : super._();

Expand Down Expand Up @@ -187,22 +182,13 @@ class DaemonOptions extends WatchOptions {
),
isReleaseBuild: argResults[releaseOption] as bool,
logPerformanceDir: argResults[logPerformanceOption] as String?,
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
enableExperiments: argResults[enableExperimentOption] as List<String>,
);
}
}

class WatchOptions extends SharedOptions {
final bool usePollingWatcher;

DirectoryWatcher Function(String) get directoryWatcherFactory =>
usePollingWatcher
? pollingDirectoryWatcherFactory
: defaultDirectoryWatcherFactory;

WatchOptions._({
required this.usePollingWatcher,
required super.buildFilters,
required super.enableLowResourcesMode,
required super.configKey,
Expand Down Expand Up @@ -240,7 +226,6 @@ class WatchOptions extends SharedOptions {
),
isReleaseBuild: argResults[releaseOption] as bool,
logPerformanceDir: argResults[logPerformanceOption] as String?,
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
enableExperiments: argResults[enableExperimentOption] as List<String>,
);
}
Expand Down Expand Up @@ -268,7 +253,6 @@ class ServeOptions extends WatchOptions {
required super.builderConfigOverrides,
required super.isReleaseBuild,
required super.logPerformanceDir,
required super.usePollingWatcher,
required super.enableExperiments,
}) : super._();

Expand Down Expand Up @@ -349,7 +333,6 @@ class ServeOptions extends WatchOptions {
),
isReleaseBuild: argResults[releaseOption] as bool,
logPerformanceDir: argResults[logPerformanceOption] as String?,
usePollingWatcher: argResults[usePollingWatcherOption] as bool,
enableExperiments: argResults[enableExperimentOption] as List<String>,
);
}
Expand Down
1 change: 0 additions & 1 deletion build_runner/lib/src/entrypoint/serve.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class ServeCommand extends WatchCommand {
builderConfigOverrides: options.builderConfigOverrides,
isReleaseBuild: options.isReleaseBuild,
logPerformanceDir: options.logPerformanceDir,
directoryWatcherFactory: options.directoryWatcherFactory,
buildFilters: options.buildFilters,
);

Expand Down
12 changes: 0 additions & 12 deletions build_runner/lib/src/entrypoint/watch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ class WatchCommand extends BuildRunnerCommand {
'Builds the specified targets, watching the file system for updates and '
'rebuilding as appropriate.';

WatchCommand() {
argParser.addFlag(
usePollingWatcherOption,
help:
'Use a polling watcher instead of the current platforms default '
'watcher implementation. This should generally only be used if '
'you are having problems with the default watcher, as it is '
'generally less efficient.',
);
}

@override
WatchOptions readOptions() => WatchOptions.fromParsedArgs(
argResults!,
Expand Down Expand Up @@ -73,7 +62,6 @@ class WatchCommand extends BuildRunnerCommand {
builderConfigOverrides: options.builderConfigOverrides,
isReleaseBuild: options.isReleaseBuild,
logPerformanceDir: options.logPerformanceDir,
directoryWatcherFactory: options.directoryWatcherFactory,
buildFilters: options.buildFilters,
);

Expand Down
6 changes: 0 additions & 6 deletions build_runner/lib/src/generate/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:build/build.dart';
import 'package:build_runner_core/build_runner_core.dart';
import 'package:logging/logging.dart';
import 'package:shelf/shelf.dart';
import 'package:watcher/watcher.dart';

import '../package_graph/build_config_overrides.dart';
import '../server/server.dart';
Expand Down Expand Up @@ -136,9 +135,6 @@ Future<BuildResult> build(
/// keep changing with less than that amount of time apart, builds will be put
/// off.
///
/// The [directoryWatcherFactory] allows you to inject a way of creating custom
/// `DirectoryWatcher`s. By default a normal `DirectoryWatcher` will be used.
///
/// The [terminateEventStream] is a stream which can send termination events.
/// By default the [ProcessSignal.sigint] stream is used. In this mode, the
/// first event will allow any ongoing builds to finish, and then the program
Expand All @@ -156,7 +152,6 @@ Future<ServeHandler> watch(
Level? logLevel,
void Function(LogRecord)? onLog,
Duration? debounceDelay,
required DirectoryWatcher Function(String) directoryWatcherFactory,
Stream<ProcessSignal>? terminateEventStream,
bool? enableLowResourcesMode,
Set<BuildDirectory>? buildDirs,
Expand All @@ -177,7 +172,6 @@ Future<ServeHandler> watch(
resolvers: resolvers,
onLog: onLog,
debounceDelay: debounceDelay,
directoryWatcherFactory: directoryWatcherFactory,
terminateEventStream: terminateEventStream,
enableLowResourcesMode: enableLowResourcesMode,
buildDirs: buildDirs,
Expand Down
6 changes: 3 additions & 3 deletions build_runner/lib/src/generate/watch_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Future<ServeHandler> watch(
Resolvers? resolvers,
void Function(LogRecord)? onLog,
Duration? debounceDelay,
required DirectoryWatcher Function(String) directoryWatcherFactory,
DirectoryWatcher Function(String)? directoryWatcherFactory,
Stream<ProcessSignal>? terminateEventStream,
bool? skipBuildScriptCheck,
bool? enableLowResourcesMode,
Expand Down Expand Up @@ -129,7 +129,7 @@ WatchImpl _runWatch(
List<BuilderApplication> builders,
Map<String, Map<String, dynamic>> builderConfigOverrides,
Future until,
DirectoryWatcher Function(String) directoryWatcherFactory,
DirectoryWatcher Function(String)? directoryWatcherFactory,
String? configKey,
bool willCreateOutputDirs,
Set<BuildDirectory> buildDirs,
Expand Down Expand Up @@ -160,7 +160,7 @@ class WatchImpl implements BuildState {
final Duration _debounceDelay;

/// Injectable factory for creating directory watchers.
final DirectoryWatcher Function(String) _directoryWatcherFactory;
final DirectoryWatcher Function(String)? _directoryWatcherFactory;

/// Whether or not we will be creating any output directories.
///
Expand Down
6 changes: 1 addition & 5 deletions build_runner/lib/src/watcher/graph_watcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ class PackageGraphWatcher {
) {
buildLog.error(
buildLog.renderThrowable(
'Error from directory watcher for '
'package:${w.node.name}\n\n'
'If you see this consistently then it is recommended that '
'you enable the polling file watcher with '
'--use-polling-watcher.',
'Failed to watch files in package:${w.node.name}.',
e,
),
);
Expand Down
Loading