Skip to content

Commit fc8a0b0

Browse files
committed
dart format .
1 parent c8c475e commit fc8a0b0

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.4
2+
3+
- dart format .
4+
15
## 0.0.3
26

37
- General/genuine packaging improvements.

example/unix_single_instance_example.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ void main(List<String> arguments) async {
2727
}
2828
}
2929
}
30-

lib/src/unix_single_instance_base.dart

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ enum ErrorMode {
3939
// false.
4040
// cmdProcessor is what the first instance does once it receives the command line arguments from the previous
4141
// kDebugMode makes the application noisy.
42-
Future<bool> unixSingleInstance(List<String> arguments,
43-
void Function(List<dynamic> args) cmdProcessor, {
44-
bool kDebugMode = false,
45-
ErrorMode errorMode = ErrorMode.exit
46-
}) async {
42+
Future<bool> unixSingleInstance(
43+
List<String> arguments, void Function(List<dynamic> args) cmdProcessor,
44+
{bool kDebugMode = false, ErrorMode errorMode = ErrorMode.exit}) async {
4745
// TODO make a named arg
4846
// Kept short because of mac os x sandboxing makes the name too long for unix sockets.
4947
var socketFilename = 'socket';
5048
// TODO make configurable so it can be per X, per User, or for the whole machine based on optional named args
5149
var configPath = await _applicationConfigDirectory();
5250
await Directory(configPath).create(recursive: true);
5351
var socketFilepath = p.join(configPath, socketFilename);
54-
final InternetAddress host = InternetAddress(socketFilepath, type: InternetAddressType.unix);
52+
final InternetAddress host =
53+
InternetAddress(socketFilepath, type: InternetAddressType.unix);
5554
var socketFile = File(socketFilepath);
5655
if (await socketFile.exists()) {
5756
if (kDebugMode) {
5857
print("Found existing instance!");
5958
}
60-
var messageSent = await _sendArgsToUixSocket(arguments, host, kDebugMode: kDebugMode);
59+
var messageSent =
60+
await _sendArgsToUixSocket(arguments, host, kDebugMode: kDebugMode);
6161
if (messageSent) {
6262
if (kDebugMode) {
6363
print("Message sent");
@@ -74,7 +74,8 @@ Future<bool> unixSingleInstance(List<String> arguments,
7474
// TODO manage socket subscription, technically not required because OS clean up does the work "for" us but good practices.
7575
// StreamSubscription<Socket>? socket;
7676
try {
77-
/*socket = */await _createUnixSocket(host, cmdProcessor, kDebugMode: kDebugMode);
77+
/*socket = */ await _createUnixSocket(host, cmdProcessor,
78+
kDebugMode: kDebugMode);
7879
} catch (e) {
7980
print("Socket create error");
8081
print(e);
@@ -86,18 +87,16 @@ Future<bool> unixSingleInstance(List<String> arguments,
8687
case ErrorMode.returnTrue:
8788
return true;
8889
case ErrorMode.returnFalse:
89-
// Pass through
90+
// Pass through
9091
}
9192
return false;
9293
}
9394
return true;
9495
}
9596

9697
// JSON serializes the args, and sends across "the wire"
97-
Future<bool> _sendArgsToUixSocket(
98-
List<String> args, InternetAddress host, {
99-
bool kDebugMode = false
100-
}) async {
98+
Future<bool> _sendArgsToUixSocket(List<String> args, InternetAddress host,
99+
{bool kDebugMode = false}) async {
101100
try {
102101
var s = await Socket.connect(host, 0);
103102
s.writeln(jsonEncode(args));
@@ -115,10 +114,9 @@ Future<bool> _sendArgsToUixSocket(
115114
// Creates the unix socket, or cleans up if it exists but isn't valid and then
116115
// recursively calls itself -- if the socket is valid, sends the args as json.
117116
// Return stream subscription.
118-
Future<StreamSubscription<Socket>> _createUnixSocket(InternetAddress host,
119-
void Function(List<dynamic> args) cmdProcessor, {
120-
bool kDebugMode = false
121-
}) async {
117+
Future<StreamSubscription<Socket>> _createUnixSocket(
118+
InternetAddress host, void Function(List<dynamic> args) cmdProcessor,
119+
{bool kDebugMode = false}) async {
122120
if (kDebugMode) {
123121
print("creating socket");
124122
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: unix_single_instance
22
description: A library which uses unix sockets to ensure a single instance
3-
version: 0.0.3
3+
version: 0.0.4
44
repository: https://github.com/arran4/dart_unix_single_instance
55
homepage: https://github.com/arran4/dart_unix_single_instance
66

0 commit comments

Comments
 (0)