Skip to content

Commit cc5118c

Browse files
committed
fix: Don’t always add "defaultIgnorePatterns" - fixes #1543
1 parent af79226 commit cc5118c

12 files changed

Lines changed: 128 additions & 4 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ node_modules
22
.idea
33
npm-debug.log
44
.sass-cache
5-
bower_components
65
test/fixtures/files/*
76
test/fixtures/js/*
87
example.server.js

cli-options/opts.start.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"type": "string",
88
"desc": "Working directory"
99
},
10+
"json": {
11+
"type": "boolean",
12+
"desc": "If true, certain logs will output as json only"
13+
},
1014
"serveStatic": {
1115
"type": "array",
1216
"alias": "ss",

crossbow.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ tasks:
1414
test:
1515
- build-all
1616
- cypress:*
17+
- cli:*
1718

1819
(cypress):
20+
file-watching-ignore: >
21+
@npm node cypress/setup/run.js
22+
'../configs/file-watching-ignore.js'
23+
cypress/integration/file-watching-ignore.js
1924
file-reloading: >
2025
@npm node cypress/setup/run.js
2126
'../configs/file-reloading.js'
@@ -61,3 +66,12 @@ tasks:
6166
client/lib/effects/*
6267
client/lib/listeners/*
6368
--write --tab-width 4
69+
70+
cli: cypress/setup/bs-cli.js
71+
72+
options:
73+
cli:
74+
file-watching-ignore:
75+
method: 'run'
76+
args: ['test/fixtures', '--files', 'test/fixtures', '--no-open', '--json']
77+
spec: 'cypress/integration/file-watching-ignore.js'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
server: 'test/fixtures',
3+
open: false,
4+
online: false,
5+
minify: false,
6+
files: 'test/fixtures',
7+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
describe('Watching folders', function() {
2+
context('files option', function () {
3+
beforeEach(function () {
4+
cy.visit(Cypress.env('BS_URL') + '/bower.html');
5+
});
6+
it('should reload single <link>', function () {
7+
cy.exec('touch test/fixtures/bower_components/app.css');
8+
cy.get('[id="css-style"]').should($link => {
9+
const url = new URL($link.attr('href'));
10+
expect(url.search).to.contain('?browsersync=');
11+
});
12+
});
13+
});
14+
});

cypress/setup/bs-cli.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const cypress = require('cypress');
2+
const exec = require('child_process');
3+
const assert = require('assert');
4+
const {Observable} = require('rxjs/Observable');
5+
6+
module.exports = function(opts) {
7+
8+
assert.ok(Array.isArray(opts.args), '`args` should be an array of strings');
9+
assert.ok(opts.args.every(arg => typeof arg === 'string'), '`args` should contain only strings');
10+
11+
return Observable.create(obs => {
12+
const ls = exec.spawn('node', [
13+
'dist/bin',
14+
...opts.args
15+
]);
16+
17+
ls.stdout.once('data', (data) => {
18+
try {
19+
const parsed = JSON.parse(String(data));
20+
const {urls} = parsed["service:running"].options;
21+
22+
return cypress.run({
23+
spec: opts.spec,
24+
env: `BS_URL=${urls.local}`
25+
})
26+
.then((results) => {
27+
// stop your server when it's complete
28+
if (results.failures > 0) {
29+
return obs.error(new Error('failed!'));
30+
}
31+
obs.complete();
32+
})
33+
} catch (e) {
34+
console.error('Parsing Browsersync output failed', e);
35+
return obs.error(new Error('failed!'));
36+
}
37+
});
38+
ls.stderr.on('data', (data) => {
39+
console.log(data);
40+
return obs.error(new Error('failed!'));
41+
});
42+
return () => {
43+
ls.kill();
44+
}
45+
});
46+
};

lib/cli/transforms/addDefaultIgnorePatterns.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const defaultIgnorePatterns = [
1010
];
1111

1212
export function addDefaultIgnorePatterns(incoming) {
13+
if (!incoming.get("watch")) {
14+
return incoming;
15+
}
16+
1317
return incoming.update("watchOptions", watchOptions => {
1418
const userIgnored = List([])
1519
.concat(watchOptions.get("ignored"))

lib/cli/transforms/copyCLIIgnoreToWatchOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function copyCLIIgnoreToWatchOptions(incoming) {
44
if (!incoming.get("ignore")) {
55
return incoming;
66
}
7-
return incoming.updateIn(["watchOptions", "ignored"], ignored => {
7+
return incoming.updateIn(["watchOptions", "ignored"], List([]), ignored => {
88
const userIgnore = List([]).concat(incoming.get("ignore"));
99
return ignored.concat(userIgnore);
1010
});

lib/logger.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ module.exports.callbacks = {
121121
* @param data
122122
*/
123123
"service:running": function(bs, data) {
124-
var type = data.type;
125-
124+
const type = data.type;
125+
if (bs.options.get('json')) {
126+
return console.log(JSON.stringify({
127+
"service:running": {
128+
"options": bs.options.toJS()
129+
}
130+
}));
131+
}
126132
if (type === "server") {
127133
var baseDir = bs.options.getIn(["server", "baseDir"]);
128134

test/fixtures/bower.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<link rel="stylesheet" id="css-style" href="bower_components/app.css">
9+
</head>
10+
<body>
11+
<h1>Bower Components</h1>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)