forked from salesforce-ux/design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.vrt.watcher.js
35 lines (32 loc) · 1.14 KB
/
jest.vrt.watcher.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
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
const { spawn, fork } = require('child_process');
const path = require('path');
const jest = spawn('./node_modules/.bin/jest', process.argv.slice(2), {
cwd: path.resolve(__dirname),
stdio: 'inherit'
});
if (process.argv.includes('--watch')) {
const glob = require('glob');
const gulp = require('gulp');
const touch = require('touch');
const paths = require('./scripts/helpers/paths');
const { watchPaths } = require('./scripts/watch');
require('./scripts/gulp/styles');
gulp.watch(watchPaths.sass, changeEvent => {
console.log(`${changeEvent.path}`);
console.log(`Compiling Sass...`);
gulp.start('styles:sass', err => {
if (err) return console.log(err);
const pattern = /ui\/(.+?)\/(.+?)\//;
const match = changeEvent.path.match(pattern);
if (match) {
const [type, id] = match.slice(1);
glob
.sync(path.resolve(__dirname, `ui/${type}/${id}/**/*.spec.{js,jsx}`))
.slice(0, 1)
.map(p => touch.sync(p));
}
});
});
}