-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwatchman-processor.config.js
93 lines (85 loc) · 2.86 KB
/
watchman-processor.config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
path = require('path');
fs = require('fs')
/**
* Custom config for watchman-processor (https://github.com/markis/watchman-processor)
* With this custom config we supply a command line argument to define the product(s) to watch.
*
* To get started, first install watchman-processor:
* `$ brew update`
* `$ brew install watchman`
* `$ npm install watchman-processor -g`
*
* Then start using this config by placing this config file in your home dir.
* Next, run watchman-processor and pass a command-line argument containing your products:
* Example usage: `$ subs=<myProduct> base=<baseProjectsFolderName> server=<serverName> watchman-processor`
*
* subs: a subscription represents the top level folder containing your project. This can be a comma separated
* list of projects if you wish to watch more than one folder, example: subs=myWebProject,myApiProject
*
* base: the base directory path that contains all your projects
*
* server: this can be the server name (from your ssh config file) or the [user@]hostAddress
*
* suffix (optional): we check if product is found at BASE_DIR/myProduct_suffix
and if not there then we check if it is found at BASE_DIR/myProduct
*
*/
const BASE_DIR = process.env.base;
const finalServerPath = process.env.server;
const SUBS = process.env['subs'].split(',');
const HOME_FOLDER = process.env['HOME'];
const suffix = process.env['suffix'];
if (!BASE_DIR || !finalServerPath || SUBS.length === 0 || !HOME_FOLDER) {
console.log(`Unable to start. Required env variables:
\n - base: ${BASE_DIR}
\n - server: ${finalServerPath}
\n - subs[]]: ${SUBS}
\n - HOME: ${HOME_FOLDER}
\n - [suffix]: ${suffix}
`);
process.exit();
}
const SUFFIX = '_trunk';
const IGNORE_FOLDERS = [
'node_modules',
'build',
'tmp',
'.gradle',
'dist',
'.idea',
'logs',
'i18n',
'.eyeglass_cache',
'bower_components',
'pemberly',
'.pemberlyrc',
'.pemberly-serve',
'.public',
'public',
'var',
];
// a command line list of products
const subscriptions= {};
SUBS.forEach((productName) => {
// check if the product requires the SUFFIX
const useSuffix = !!suffix && fs.existsSync(`${BASE_DIR}/${productName}${SUFFIX}/`);
const productDir = useSuffix ? `${BASE_DIR}/${productName}${SUFFIX}/` : `${BASE_DIR}/${productName}/`;
if (!fs.existsSync(`${BASE_DIR}/${productName}/`)) {
console.log(`path not valid for ${productName} at ${BASE_DIR}/${productName}${SUFFIX} or ${BASE_DIR}/${productName}`);
process.exit();
}
subscriptions[productName] = {
type: 'rsync',
source: path.join(HOME_FOLDER, `${productDir}/`),
destination: `${finalServerPath}:~/${productDir}/`,
ignoreFolders: IGNORE_FOLDERS
}
});
module.exports = {
debug: false,
emoji: true,
controlWatchman: true,
rsyncCmd: 'rsync',
maxFileLength: 100,
subscriptions
};