Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit ad9c586

Browse files
author
Orta
authored
Merge pull request #979 from flatiron32/globQuotes
Quotes used consistently in gulp tutorial.
2 parents 2493176 + 7f07716 commit ad9c586

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

pages/tutorials/Gulp.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ In `src`, create the file `main.ts`:
6868
function hello(compiler: string) {
6969
console.log(`Hello from ${compiler}`);
7070
}
71-
hello("TypeScript");
71+
hello('TypeScript');
7272
```
7373

7474
In the project root, `proj`, create the file `tsconfig.json`:
@@ -90,14 +90,14 @@ In the project root, `proj`, create the file `tsconfig.json`:
9090
In the project root, create the file `gulpfile.js`:
9191

9292
```js
93-
var gulp = require("gulp");
94-
var ts = require("gulp-typescript");
95-
var tsProject = ts.createProject("tsconfig.json");
93+
var gulp = require('gulp');
94+
var ts = require('gulp-typescript');
95+
var tsProject = ts.createProject('tsconfig.json');
9696

97-
gulp.task("default", function () {
97+
gulp.task('default', function () {
9898
return tsProject.src()
9999
.pipe(tsProject())
100-
.js.pipe(gulp.dest("dist"));
100+
.js.pipe(gulp.dest('dist'));
101101
});
102102
```
103103

@@ -126,9 +126,9 @@ export function sayHello(name: string) {
126126
Now change the code in `src/main.ts` to import `sayHello` from `greet.ts`:
127127

128128
```ts
129-
import { sayHello } from "./greet";
129+
import { sayHello } from './greet';
130130

131-
console.log(sayHello("TypeScript"));
131+
console.log(sayHello('TypeScript'));
132132
```
133133

134134
Finally, add `src/greet.ts` to `tsconfig.json`:
@@ -193,34 +193,34 @@ Create a file in `src` named `index.html`:
193193
Now change `main.ts` to update the page:
194194

195195
```ts
196-
import { sayHello } from "./greet";
196+
import { sayHello } from './greet';
197197

198198
function showHello(divName: string, name: string) {
199199
const elt = document.getElementById(divName);
200200
elt.innerText = sayHello(name);
201201
}
202202

203-
showHello("greeting", "TypeScript");
203+
showHello('greeting', 'TypeScript');
204204
```
205205

206206
Calling `showHello` calls `sayHello` to change the paragraph's text.
207207
Now change your gulpfile to the following:
208208

209209
```js
210-
var gulp = require("gulp");
211-
var browserify = require("browserify");
210+
var gulp = require('gulp');
211+
var browserify = require('browserify');
212212
var source = require('vinyl-source-stream');
213-
var tsify = require("tsify");
213+
var tsify = require('tsify');
214214
var paths = {
215215
pages: ['src/*.html']
216216
};
217217

218-
gulp.task("copy-html", function () {
218+
gulp.task('copy-html', function () {
219219
return gulp.src(paths.pages)
220-
.pipe(gulp.dest("dist"));
220+
.pipe(gulp.dest('dist'));
221221
});
222222

223-
gulp.task("default", gulp.series(gulp.parallel('copy-html'), function () {
223+
gulp.task('default', gulp.series(gulp.parallel('copy-html'), function () {
224224
return browserify({
225225
basedir: '.',
226226
debug: true,
@@ -231,7 +231,7 @@ gulp.task("default", gulp.series(gulp.parallel('copy-html'), function () {
231231
.plugin(tsify)
232232
.bundle()
233233
.pipe(source('bundle.js'))
234-
.pipe(gulp.dest("dist"));
234+
.pipe(gulp.dest('dist'));
235235
}));
236236
```
237237

@@ -274,12 +274,12 @@ npm install --save-dev watchify fancy-log
274274
Now change your gulpfile to the following:
275275

276276
```js
277-
var gulp = require("gulp");
278-
var browserify = require("browserify");
277+
var gulp = require('gulp');
278+
var browserify = require('browserify');
279279
var source = require('vinyl-source-stream');
280-
var watchify = require("watchify");
281-
var tsify = require("tsify");
282-
var fancy_log = require("fancy-log");
280+
var watchify = require('watchify');
281+
var tsify = require('tsify');
282+
var fancy_log = require('fancy-log');
283283
var paths = {
284284
pages: ['src/*.html']
285285
};
@@ -292,28 +292,28 @@ var watchedBrowserify = watchify(browserify({
292292
packageCache: {}
293293
}).plugin(tsify));
294294

295-
gulp.task("copy-html", function () {
295+
gulp.task('copy-html', function () {
296296
return gulp.src(paths.pages)
297-
.pipe(gulp.dest("dist"));
297+
.pipe(gulp.dest('dist'));
298298
});
299299

300300
function bundle() {
301301
return watchedBrowserify
302302
.bundle()
303303
.pipe(source('bundle.js'))
304-
.pipe(gulp.dest("dist"));
304+
.pipe(gulp.dest('dist'));
305305
}
306306

307-
gulp.task("default", gulp.series(gulp.parallel('copy-html'), bundle));
308-
watchedBrowserify.on("update", bundle);
309-
watchedBrowserify.on("log", fancy_log);
307+
gulp.task('default', gulp.series(gulp.parallel('copy-html'), bundle));
308+
watchedBrowserify.on('update', bundle);
309+
watchedBrowserify.on('log', fancy_log);
310310
```
311311

312312
There are basically three changes here, but they require you to refactor your code a bit.
313313

314314
1. We wrapped our `browserify` instance in a call to `watchify`, and then held on to the result.
315-
2. We called `watchedBrowserify.on("update", bundle);` so that Browserify will run the `bundle` function every time one of your TypeScript files changes.
316-
3. We called `watchedBrowserify.on("log", gutil.log);` to log to the console.
315+
2. We called `watchedBrowserify.on('update', bundle);` so that Browserify will run the `bundle` function every time one of your TypeScript files changes.
316+
3. We called `watchedBrowserify.on('log', gutil.log);` to log to the console.
317317

318318
Together (1) and (2) mean that we have to move our call to `browserify` out of the `default` task.
319319
And we have to give the function for `default` a name since both Watchify and Gulp need to call it.
@@ -347,23 +347,23 @@ npm install --save-dev gulp-uglify vinyl-buffer gulp-sourcemaps
347347
Now change your gulpfile to the following:
348348

349349
```js
350-
var gulp = require("gulp");
351-
var browserify = require("browserify");
350+
var gulp = require('gulp');
351+
var browserify = require('browserify');
352352
var source = require('vinyl-source-stream');
353-
var tsify = require("tsify");
353+
var tsify = require('tsify');
354354
var uglify = require('gulp-uglify');
355355
var sourcemaps = require('gulp-sourcemaps');
356356
var buffer = require('vinyl-buffer');
357357
var paths = {
358358
pages: ['src/*.html']
359359
};
360360

361-
gulp.task("copy-html", function () {
361+
gulp.task('copy-html', function () {
362362
return gulp.src(paths.pages)
363-
.pipe(gulp.dest("dist"));
363+
.pipe(gulp.dest('dist'));
364364
});
365365

366-
gulp.task("default", gulp.series(gulp.parallel('copy-html'), function () {
366+
gulp.task('default', gulp.series(gulp.parallel('copy-html'), function () {
367367
return browserify({
368368
basedir: '.',
369369
debug: true,
@@ -378,7 +378,7 @@ gulp.task("default", gulp.series(gulp.parallel('copy-html'), function () {
378378
.pipe(sourcemaps.init({loadMaps: true}))
379379
.pipe(uglify())
380380
.pipe(sourcemaps.write('./'))
381-
.pipe(gulp.dest("dist"));
381+
.pipe(gulp.dest('dist'));
382382
}));
383383
```
384384

0 commit comments

Comments
 (0)