本文整理匯總了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);
});