Gulp.src():在哪里读取文件?

时间:2016-03-28 15:26:17

标签: node.js gulp

我有以下代码,但它无法从src文件夹中读取文件。有谁知道gulp从哪里读取文件的路径?

Gtk.Entry

文件夹结构:

class TextEntry(Gtk.Entry):
    def __init__(self, window):
        Gtk.Entry.__init__(self)
        self.keyboard = window.keyboard

        self.connect("focus-in-event", self.on_focus_in)
        self.connect("focus-out-event", self.on_focus_out)

    def on_focus_in(self, event, data):
        self.keyboard.show()

    def on_focus_out(self, event, data):
        self.keyboard.hide()

2 个答案:

答案 0 :(得分:0)

我想 - 因为我不是Node.js专家 - Gulp使用当前的工作目录 包含package.json和Gulp脚本的目录。

因此,在app / gulp目录中调用Gulp时,您可以放弃:

gulp.task('default', function() {
    return gulp.src('src/*')
      .pipe() ...//other code
});

您也可以使用该目录中的相对路径,如下所示:

gulp.task('other', function() {
    return gulp.src('../../whatever/*')
      .pipe() ...//other code
});

答案 1 :(得分:0)

__dirname全局返回当前目录,并且最后不会包含aditional斜杠,因此连接'./otherDir'将变为'/dir./otherDir'。 只需从字符串中删除点即可连接。 https://nodejs.org/docs/latest/api/globals.html