Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
[removed] the watchDir argument from DevServer#watchSASS and `Dev…
Browse files Browse the repository at this point in the history
…Server#run`, opting into watching the CWD instead
thealjey committed Jul 7, 2016
1 parent 60d2bb8 commit 9da3694
Showing 7 changed files with 31 additions and 133 deletions.
108 changes: 4 additions & 104 deletions docs/DevServer.html
Original file line number Diff line number Diff line change
@@ -373,7 +373,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="DevServer.js.html">DevServer.js</a>,
<a href="DevServer.js.html#sunlight-1-line-13">line 13</a>
<a href="DevServer.js.html#sunlight-1-line-14">line 14</a>
</li>
</ul>
</dd>
@@ -450,7 +450,7 @@ <h3 class="subsection-title">Methods</h3>

<hr>
<dt>
<h4 class="name" id="run"><span class="type-signature"></span>run(watchDir)</h4>
<h4 class="name" id="run"><span class="type-signature"></span>run()</h4>


</dt>
@@ -468,56 +468,6 @@ <h4 class="name" id="run"><span class="type-signature"></span>run(watchDir)</h4>



<h5>Parameters:</h5>


<table class="params table table-striped">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>watchDir</code></td>


<td class="type">


<span class="param-type">string</span>




</td>





<td class="description last"><p>the directory in which to watch for the changes in the SASS files</p></td>
</tr>


</tbody>
</table>




<dl class="details">
@@ -688,7 +638,7 @@ <h5>Example</h5>

<hr>
<dt>
<h4 class="name" id="watchSASS"><span class="type-signature"></span>watchSASS(watchDir)</h4>
<h4 class="name" id="watchSASS"><span class="type-signature"></span>watchSASS()</h4>


</dt>
@@ -706,56 +656,6 @@ <h4 class="name" id="watchSASS"><span class="type-signature"></span>watchSASS(wa



<h5>Parameters:</h5>


<table class="params table table-striped">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>watchDir</code></td>


<td class="type">


<span class="param-type">string</span>




</td>





<td class="description last"><p>the directory in which to watch for the changes in the SASS files</p></td>
</tr>


</tbody>
</table>




<dl class="details">
@@ -793,7 +693,7 @@ <h5>Parameters:</h5>
<ul class="dummy">
<li>
<a href="DevServer.js.html">DevServer.js</a>,
<a href="DevServer.js.html#sunlight-1-line-154">line 154</a>
<a href="DevServer.js.html#sunlight-1-line-155">line 155</a>
</li>
</ul>
</dd>
13 changes: 6 additions & 7 deletions docs/DevServer.js.html
Original file line number Diff line number Diff line change
@@ -92,7 +92,8 @@ <h1 class="page-title">Source: DevServer.js</h1>
import {join} from 'path';

const LIVERELOAD_PORT = 35729,
WEB_PORT = 3000;
WEB_PORT = 3000,
cwd = process.cwd();

/**
* A lightweight development server that rapidly recompiles the JavaScript and SASS files when they are edited and
@@ -241,14 +242,13 @@ <h1 class="page-title">Source: DevServer.js</h1>
* @memberof DevServer
* @instance
* @method watchSASS
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.watchSASS('/path/to/some/directory');
*/
watchSASS(watchDir: string) {
watchSASS() {
this.lr.listen(LIVERELOAD_PORT);
this.compileSASS();
watch(watchDir, 'scss', this.compileSASS);
watch(cwd, 'scss', this.compileSASS);
}

/**
@@ -277,13 +277,12 @@ <h1 class="page-title">Source: DevServer.js</h1>
* @memberof DevServer
* @instance
* @method run
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.run('/path/to/some/directory');
*/
run(watchDir: string) {
run() {
this.watchJS();
this.watchSASS(watchDir);
this.watchSASS();
}

}
2 changes: 1 addition & 1 deletion docs/quicksearch.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions interfaces/webcompiler.js
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ declare module 'webcompiler' {

declare class DevServer {
constructor(script: string, style: string, devDir: string, port: ?number, react: ?boolean): void;
watchSASS(watchDir: string): void;
watchSASS(): void;
watchJS(): void;
run(watchDir: string): void;
run(): void;
}

declare class JSLint {
13 changes: 6 additions & 7 deletions lib/DevServer.js
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ var _path = require('path');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var LIVERELOAD_PORT = 35729,
WEB_PORT = 3000;
WEB_PORT = 3000,
cwd = process.cwd();

/**
* A lightweight development server that rapidly recompiles the JavaScript and SASS files when they are edited and
@@ -146,7 +147,6 @@ var DevServer = exports.DevServer = function () {
* @memberof DevServer
* @instance
* @method watchSASS
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.watchSASS('/path/to/some/directory');
*/
@@ -172,10 +172,10 @@ var DevServer = exports.DevServer = function () {
*/


DevServer.prototype.watchSASS = function watchSASS(watchDir) {
DevServer.prototype.watchSASS = function watchSASS() {
this.lr.listen(LIVERELOAD_PORT);
this.compileSASS();
(0, _watch.watch)(watchDir, 'scss', this.compileSASS);
(0, _watch.watch)(cwd, 'scss', this.compileSASS);
};

/**
@@ -206,15 +206,14 @@ var DevServer = exports.DevServer = function () {
* @memberof DevServer
* @instance
* @method run
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.run('/path/to/some/directory');
*/


DevServer.prototype.run = function run(watchDir) {
DevServer.prototype.run = function run() {
this.watchJS();
this.watchSASS(watchDir);
this.watchSASS();
};

return DevServer;
13 changes: 6 additions & 7 deletions src/DevServer.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@ import webpack from 'webpack';
import {join} from 'path';

const LIVERELOAD_PORT = 35729,
WEB_PORT = 3000;
WEB_PORT = 3000,
cwd = process.cwd();

/**
* A lightweight development server that rapidly recompiles the JavaScript and SASS files when they are edited and
@@ -157,14 +158,13 @@ export class DevServer {
* @memberof DevServer
* @instance
* @method watchSASS
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.watchSASS('/path/to/some/directory');
*/
watchSASS(watchDir: string) {
watchSASS() {
this.lr.listen(LIVERELOAD_PORT);
this.compileSASS();
watch(watchDir, 'scss', this.compileSASS);
watch(cwd, 'scss', this.compileSASS);
}

/**
@@ -193,13 +193,12 @@ export class DevServer {
* @memberof DevServer
* @instance
* @method run
* @param {string} watchDir - the directory in which to watch for the changes in the SASS files
* @example
* server.run('/path/to/some/directory');
*/
run(watchDir: string) {
run() {
this.watchJS();
this.watchSASS(watchDir);
this.watchSASS();
}

}
11 changes: 6 additions & 5 deletions test/DevServer.spec.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ chai.use(sinonChai);

const DEFAULT_WEB_PORT = 3000,
WEB_PORT = 8000,
LIVERELOAD_PORT = 35729;
LIVERELOAD_PORT = 35729,
cwd = process.cwd();

let DevServer, cmp, tinylr, webpack, srv, send, watch;

@@ -195,7 +196,7 @@ describe('DevServer', () => {
beforeEach(() => {
stub(cmp.lr, 'listen');
stub(cmp, 'compileSASS');
cmp.watchSASS('/path/to/some/directory');
cmp.watchSASS();
});

afterEach(() => {
@@ -212,7 +213,7 @@ describe('DevServer', () => {
});

it('starts up the watcher', () => {
expect(watch).calledWith('/path/to/some/directory', 'scss', cmp.compileSASS);
expect(watch).calledWith(cwd, 'scss', cmp.compileSASS);
});

});
@@ -268,7 +269,7 @@ describe('DevServer', () => {
beforeEach(() => {
stub(cmp, 'watchJS');
stub(cmp, 'watchSASS');
cmp.run('/path/to/some/directory');
cmp.run();
});

afterEach(() => {
@@ -281,7 +282,7 @@ describe('DevServer', () => {
});

it('invokes the watchSASS method', () => {
expect(cmp.watchSASS).calledWith('/path/to/some/directory');
expect(cmp.watchSASS).called;
});

});

0 comments on commit 9da3694

Please sign in to comment.