-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwatch-templates.js
37 lines (32 loc) · 975 Bytes
/
watch-templates.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var chokidar = require('chokidar');
var exec = require('child_process').exec;
var fs = require('fs');
var path = require('path');
var watcher = chokidar.watch('assets', {
ignored: /[\/\\]\./,
persistent: true
});
watcher
.on('add', function(path) {
console.log('File', path, 'has been added');
pushFile(path);
})
.on('change', function(path) {
console.log('File', path, 'has been changed');
pushFile(path);
})
.on('unlink', function(path) {
console.log('File', path, 'has been removed');
});
function pushFile(file) {
var filename = path.basename(file);
var destination = '/sdcard/bsml/GraphicsTweaks/' + filename;
exec('adb push ' + file + ' ' + destination, function(error, stdout, stderr) {
if (error) {
console.log('Error pushing file: ' + error);
}
else {
console.log('Pushed ' + file + ' to ' + destination);
}
});
}