V
V
Vyacheslav Lebedev2015-04-23 15:04:02
Node.js
Vyacheslav Lebedev, 2015-04-23 15:04:02

Problem with node, gulp asynchrony - tasks?

Good afternoon!
Faced the problem of node asynchrony and I don’t understand how to deal with it.
While it used to work as it should.
As far as I know, when executing tasks, if a node lingers on one of them, then it moves on, creating asynchronous execution.
Here are 2 tasks. The first of them must be executed, and then only the second. Since the first one creates a compiled file by writing to the tmp folder.
Perhaps you can tell me how to do without writing to tmp, but make it a stream.
My experience with gulp does not allow me to come up with something that does not greatly complicate the logic:

gulp.task('coffee', function () {
    gulp.src(paths.src.coffee)
        .pipe(coffee())
        .pipe(concat('buildCoffee.js'))
        .pipe(gulp.dest(paths.build.tmp));
});

gulp.task('scripts', ['coffee'], function () {
    gulp.src(paths.src.libsJS)
        .pipe(concat('all.js'))
        .pipe(gulp.dest(paths.build.scripts));
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey B., 2015-04-23
@slavikse

Try adding return to gulp.src(paths.src.coffee)

gulp.task('coffee', function () {
    return gulp.src(paths.src.coffee)
        .pipe(coffee())
        .pipe(concat('buildCoffee.js'))
        .pipe(gulp.dest(paths.build.tmp));
});

UPD: or I misunderstood you, do you need the second task to not run until the first one is completed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question