Skip to content

Commit 5bd195b

Browse files
authored
feat!: return encoding everywhere (#62)
1 parent 5cf4e7f commit 5bd195b

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

simctl.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
extensions: SimCtlExtensions,
3030

3131
check_prerequisites: function () {
32-
const result = spawnSync('xcrun', ['simctl', 'help'], { stdio: 'ignore' })
32+
const result = spawnSync('xcrun', ['simctl', 'help'], { stdio: 'ignore', encoding: 'utf8' })
3333

3434
if (result.status !== 0) {
3535
result.stdout = 'simctl was not found.\n'
@@ -43,63 +43,63 @@ module.exports = {
4343
},
4444

4545
simctl_version: function () {
46-
const res = spawnSync('xcrun', ['simctl', '--version'])
46+
const res = spawnSync('xcrun', ['simctl', '--version'], { encoding: 'utf8' })
4747
const versionMatch = /CoreSimulator-(.*)/.exec(res.stdout)
4848
const versionString = versionMatch[1]
4949

5050
return versionString.split('.').map((v) => parseInt(v, 10))
5151
},
5252

5353
xcode_version: function () {
54-
const res = spawnSync('xcodebuild', ['-version'])
54+
const res = spawnSync('xcodebuild', ['-version'], { encoding: 'utf8' })
5555
const versionMatch = /Xcode (.*)/.exec(res.stdout)
5656
const versionString = versionMatch[1]
5757

5858
return versionString.split('.').map((v) => parseInt(v, 10))
5959
},
6060

6161
create: function (name, deviceTypeId, runtimeId) {
62-
return spawnSync('xcrun', ['simctl', 'create', name, deviceTypeId, runtimeId])
62+
return spawnSync('xcrun', ['simctl', 'create', name, deviceTypeId, runtimeId], { encoding: 'utf8' })
6363
},
6464

6565
del: function (device) {
66-
return spawnSync('xcrun', ['simctl', 'delete', device])
66+
return spawnSync('xcrun', ['simctl', 'delete', device], { encoding: 'utf8' })
6767
},
6868

6969
erase: function (device) {
70-
return spawnSync('xcrun', ['simctl', 'erase', device])
70+
return spawnSync('xcrun', ['simctl', 'erase', device], { encoding: 'utf8' })
7171
},
7272

7373
boot: function (device) {
74-
return spawnSync('xcrun', ['simctl', 'boot', device])
74+
return spawnSync('xcrun', ['simctl', 'boot', device], { encoding: 'utf8' })
7575
},
7676

7777
shutdown: function (device) {
78-
return spawnSync('xcrun', ['simctl', 'shutdown', device])
78+
return spawnSync('xcrun', ['simctl', 'shutdown', device], { encoding: 'utf8' })
7979
},
8080

8181
rename: function (device, name) {
82-
return spawnSync('xcrun', ['simctl', 'rename', device, name])
82+
return spawnSync('xcrun', ['simctl', 'rename', device, name], { encoding: 'utf8' })
8383
},
8484

8585
getenv: function (device, variableName) {
86-
return spawnSync('xcrun', ['simctl', 'getenv', device, variableName])
86+
return spawnSync('xcrun', ['simctl', 'getenv', device, variableName], { encoding: 'utf8' })
8787
},
8888

8989
openurl: function (device, url) {
90-
return spawnSync('xcrun', ['simctl', 'openurl', device, url])
90+
return spawnSync('xcrun', ['simctl', 'openurl', device, url], { encoding: 'utf8' })
9191
},
9292

9393
addphoto: function (device, path) {
94-
return spawnSync('xcrun', ['simctl', 'addphoto', device, path])
94+
return spawnSync('xcrun', ['simctl', 'addphoto', device, path], { encoding: 'utf8' })
9595
},
9696

9797
install: function (device, path) {
98-
return spawnSync('xcrun', ['simctl', 'install', device, path])
98+
return spawnSync('xcrun', ['simctl', 'install', device, path], { encoding: 'utf8' })
9999
},
100100

101101
uninstall: function (device, appIdentifier) {
102-
return spawnSync('xcrun', ['simctl', 'uninstall', device, appIdentifier])
102+
return spawnSync('xcrun', ['simctl', 'uninstall', device, appIdentifier], { encoding: 'utf8' })
103103
},
104104

105105
launch: function (device, appIdentifier, argv = [], options = {}) {
@@ -122,7 +122,7 @@ module.exports = {
122122
args.push(appIdentifier)
123123
args.push(...argv)
124124

125-
return spawnSync('xcrun', args)
125+
return spawnSync('xcrun', args, { encoding: 'utf8' })
126126
},
127127

128128
spawn: function (device, pathToExecutable, argv = [], options = {}) {
@@ -139,7 +139,7 @@ module.exports = {
139139
args.push(pathToExecutable)
140140
args.push(...argv)
141141

142-
return spawnSync('xcrun', args)
142+
return spawnSync('xcrun', args, { encoding: 'utf8' })
143143
},
144144

145145
list: function (options) {
@@ -156,7 +156,7 @@ module.exports = {
156156
sublist.push('pairs')
157157
}
158158

159-
const result = spawnSync('xcrun', ['simctl', 'list'].concat(sublist, ['--json']))
159+
const result = spawnSync('xcrun', ['simctl', 'list'].concat(sublist, ['--json']), { encoding: 'utf8' })
160160

161161
if (result.status === 0) {
162162
try {
@@ -170,26 +170,26 @@ module.exports = {
170170
},
171171

172172
notify_post: function (device, notificationName) {
173-
return spawnSync('xcrun', ['simctl', 'notify_post', device, notificationName])
173+
return spawnSync('xcrun', ['simctl', 'notify_post', device, notificationName], { encoding: 'utf8' })
174174
},
175175

176176
icloud_sync: function (device) {
177-
return spawnSync('xcrun', ['simctl', 'icloud_sync', device])
177+
return spawnSync('xcrun', ['simctl', 'icloud_sync', device], { encoding: 'utf8' })
178178
},
179179

180180
help: function (subcommand) {
181181
if (subcommand) {
182-
return spawnSync('xcrun', ['simctl', 'help', subcommand])
182+
return spawnSync('xcrun', ['simctl', 'help', subcommand], { encoding: 'utf8' })
183183
} else {
184-
return spawnSync('xcrun', ['simctl', 'help'])
184+
return spawnSync('xcrun', ['simctl', 'help'], { encoding: 'utf8' })
185185
}
186186
},
187187

188188
pair: function (watchDevice, phoneDevice) {
189-
return spawnSync('xcrun', ['simctl', 'pair', watchDevice, phoneDevice])
189+
return spawnSync('xcrun', ['simctl', 'pair', watchDevice, phoneDevice], { encoding: 'utf8' })
190190
},
191191

192192
unpair: function (pairUUID) {
193-
return spawnSync('xcrun', ['simctl', 'unpair', pairUUID])
193+
return spawnSync('xcrun', ['simctl', 'unpair', pairUUID], { encoding: 'utf8' })
194194
}
195195
}

0 commit comments

Comments
 (0)