Tack Paul F! din lösning fungerade. Jag tog bort det sista argumentet från spawn och la till min kod:
mysqlimport.stdin.write( '\\. /Users/user/dumps/' + fileName );
mysqlimport.stdin.end();
Så sammantaget ser det ut som:
var mysqlimport = spawn('/usr/local/bin/mysql', [
'-u' + database.user,
'-p' + database.password,
'-h' + database.address,
'--default-character-set=utf8',
'--comments'
]);
mysqlimport.stdin.write( '\\. /Users/user/dumps/' + fileName );
mysqlimport.stdin.end();
mysqlimport
.stdout
.pipe(logFile)
.on('data', function(data) {
console.log(data);
})
.on('finish', function() {
console.log('finished')
})
.on('error', function(err) {
console.log(err)
});