本文整理汇总了TypeScript中vinyl-fs.src函数的典型用法代码示例。如果您正苦于以下问题:TypeScript src函数的具体用法?TypeScript src怎么用?TypeScript src使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了src函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should glob a file with streaming contents', done => {
const expectedPath = path.join(__dirname, "./fixtures/test.coffee");
const expectedContent = fs.readFileSync(expectedPath);
const onEnd = () => {
buffered.length.should.equal(1);
should.exist(buffered[0].stat);
buffered[0].path.should.equal(expectedPath);
buffered[0].isStream().should.equal(true);
let contentBuffer = new Buffer([]);
const contentBufferStream = through(dataWrap((data: any) => {
contentBuffer = Buffer.concat([contentBuffer, data]);
}));
buffered[0].contents.pipe(contentBufferStream);
buffered[0].contents.once('end', () => {
bufEqual(contentBuffer, expectedContent);
done();
});
};
const stream = vfs.src("./fixtures/*.coffee", { cwd: __dirname, buffer: false });
const buffered: any = [];
bufferStream = through.obj(dataWrap(buffered.push.bind(buffered)), onEnd);
stream.pipe(bufferStream);
});
示例2: Promise
return new Promise((resolve, reject) => {
debug(`processAssets ${src} to ${dest}`);
vfs.src(`${src}/**/*.ts`)
.pipe(inlineNg2Template({
base: `${src}`,
useRelativePaths: true,
styleProcessor: (path, ext, file, cb) => {
debug(`render stylesheet ${path}`);
const render = pickRenderer(path, ext, file);
debug(`postcss with autoprefixer for ${path}`);
const browsers = browserslist(undefined, { path });
render.then((css: string) => postcss([ autoprefixer({ browsers }) ]).process(css))
.then((result) => {
result.warnings().forEach((msg) => {
warn(msg.toString());
});
cb(undefined, result.css);
})
.catch((err) => {
cb(err || new Error(`Cannot inline stylesheet ${path}`));
});
}
}))
.on('error', reject)
.pipe(vfs.dest(`${dest}`))
.on('end', resolve);
});
示例3: it
it('should skip null', (done) => {
vfs.src('lib', {
stripBOM: false,
}).pipe(eclint.fix()).on('data', (file: eclint.IEditorConfigLintFile) => {
expect(file.editorconfig).not.to.be.ok;
}).on('end', () => {
done();
}).on('error', done);
});
示例4: src
src() {
let configPath = path.dirname(this.configFileName)
let base: string;
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
base = path.resolve(configPath, this.config.compilerOptions.rootDir);
} else {
base = configPath;
}
if (!this.config.files) {
let files = [path.join(base, '**/*.ts')];
if (this.config.excludes instanceof Array) {
files = files.concat(this.config.excludes.map(file => '!' + path.resolve(base, file)));
}
return vfs.src(files);
}
const resolvedFiles: string[] = [];
const checkMissingFiles = through2.obj(function (file: gutil.File, enc, callback) {
this.push(file);
resolvedFiles.push(utils.normalizePath(file.path));
callback();
});
checkMissingFiles.on('finish', () => {
for (const fileName of this.config.files) {
const fullPaths = [
utils.normalizePath(path.join(configPath, fileName)),
utils.normalizePath(path.join(process.cwd(), configPath, fileName))
];
if (resolvedFiles.indexOf(fullPaths[0]) === -1 && resolvedFiles.indexOf(fullPaths[1]) === -1) {
const error = new Error(`error TS6053: File '${ fileName }' not found.`);
console.error(error.message);
checkMissingFiles.emit('error', error);
}
}
});
return vfs.src(this.config.files.map(file => path.resolve(base, file)), { base })
.pipe(checkMissingFiles);
}
示例5: src
src() {
if (!this.config.files) {
throw new Error('gulp-typescript: You can only use src() if the \'files\' property exists in your tsconfig.json. Use gulp.src(\'**/**.ts\') instead.');
}
let base = path.dirname(this.configFileName);
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
base = path.resolve(base, this.config.compilerOptions.rootDir);
}
return vfs.src(this.config.files.map(file => path.resolve(base, file)), { base });
}
示例6: it
it('should not be applied no mdfile is available', done => {
fs.src(['src/articles/tomcat-initd-*.md'], {
base: path.join(__dirname, '../../')
})
.pipe(toArticle())
.pipe(
through.obj(function(chunk, enc, cb) {
expect(chunk.path).toContain('tomcat-initd-script.md');
cb();
})
)
.on('finish', done);
});