-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync.js
More file actions
executable file
·32 lines (25 loc) · 1.03 KB
/
sync.js
File metadata and controls
executable file
·32 lines (25 loc) · 1.03 KB
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
#!/usr/bin/env node
const syncDirectory = require('sync-directory');
const { join } = require('path');
const rimraf = require('rimraf');
const mainDir = join(__dirname, 'common');
const sync = (target, watch = true) => {
const absoluteTarget = join(__dirname, target, 'src', 'common');
rimraf.sync(absoluteTarget);
const watcher = syncDirectory(mainDir, absoluteTarget, {
watch,
exclude: ['node_modules', 'package.json'],
});
const { log } = console;
if (watcher)
watcher
.on('ready', () => log(`Initial scan complete for ${target}. Ready for changes...`))
.on('change', (path) => log(`File ${path} has been changed`))
.on('unlink', (path) => log(`File ${path} has been removed`))
.on('unlinkDir', (path) => log(`Directory ${path} has been removed`))
.on('error', (error) => log(`Watcher error: ${error}`));
else console.log(`Done copping files for ${target}...`);
};
module.exports = sync;
const args = process.argv.slice(2);
if (args[0] === 'web' || args[0] === 'native') sync(args[0]);