Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit cd1983c

Browse files
author
Emil Öberg
committed
re-added full builds to gulp script as livesync builds does NOT give terminal outputs (see NativeScript/nativescript-cli#763 )
1 parent d4cd7ef commit cd1983c

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ gulp startIOS
2828
# To watch for file changes. When a file is changed
2929
# the source is recomipled (from ES2015 to ES5) and
3030
# changes pushed to the emulator.
31-
gulp watchIOS
31+
gulp livesyncIOS
3232
```
3333

34+
or run:
35+
36+
```
37+
gulp watchFullIOS
38+
```
39+
40+
Currently, NativeScript does unfortunately not display `console.log` or exception statements in the terminal when running with livesync. Therefor we still have to do full rebuilds with the `watchFullIOS` command to get terminal outputs.
41+
42+
3443
### File structure
3544
```
3645
| - gulpfile.js - Development gulp file (for recompiling, etc)

gulpfile.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ gulp.task('startIOS', function(cb) {
102102
cb();
103103
});
104104

105-
gulp.task('watchIOS', function(callback) {
105+
gulp.task('livesyncIOS', function(callback) {
106106
console.log();
107107
console.log(chalk.blue('Watcher started, will restart emulator when files change'));
108108
console.log();
@@ -116,6 +116,21 @@ gulp.task('watchIOS', function(callback) {
116116
);
117117
});
118118

119+
gulp.task('watchFullIOS', function(callback) {
120+
console.log();
121+
console.log(chalk.blue('Watcher started, will restart emulator when files change'));
122+
console.log();
123+
gulp.watch(watchedFiles, function () {
124+
runSequence(
125+
'_clean',
126+
'_compile',
127+
'_watchFullIOS',
128+
callback);
129+
}
130+
);
131+
});
132+
133+
119134
gulp.task('lint', function () {
120135
return gulp.src(babelSrc)
121136
.pipe(eslint())
@@ -200,6 +215,31 @@ gulp.task('_livesyncIOS', function(cb) {
200215

201216
});
202217

218+
gulp.task('_watchFullIOS', function(cb) {
219+
var child = spawn('tns', ['emulate', 'ios', '--device', iOSEmulator], {cwd: process.cwd() + '/' + pathToStartAppFrom});
220+
var stdout = '';
221+
var stderr = '';
222+
223+
child.stdout.setEncoding('utf8');
224+
child.stdout.on('data', function (data) {
225+
stdout += data;
226+
console.log(data);
227+
});
228+
229+
child.stderr.setEncoding('utf8');
230+
child.stderr.on('data', function (data) {
231+
stderr += data;
232+
console.log(chalk.red(data));
233+
});
234+
235+
child.on('close', function(code) {
236+
console.log('Done with exit code', code);
237+
});
238+
239+
cb();
240+
241+
});
242+
203243
gulp.task('_emulateAndroid', function(cb) {
204244
//▶ tns emulate android --geny Nexus-5
205245
var child = spawn('tns', ['emulate', 'android', '--geny', androidEmulator], {cwd: process.cwd()});
@@ -448,7 +488,7 @@ gulp.task('default', function() {
448488
console.log();
449489
console.log(chalk.magenta(' Main tasks'));
450490
console.log();
451-
console.log(' ' + chalk.blue('gulp watchIOS') + ' - Start watching files, recompile Javascript and restart');
491+
console.log(' ' + chalk.blue('gulp livesyncIOS') + ' - Start watching files, recompile Javascript and restart');
452492
console.log(' emulator (set to: ' + iOSEmulator + ') when files change.');
453493
console.log();
454494
console.log(' ' + chalk.blue('gulp watchAndroid') + ' - Start watching files, recompile Javascript and restart');

0 commit comments

Comments
 (0)