当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vinyl-fs.src函数代码示例

本文整理汇总了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);
   });
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:27,代码来源:vinyl-fs-tests.ts

示例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);
  });
开发者ID:davidenke,项目名称:ng-packagr,代码行数:33,代码来源:assets.ts

示例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);
		});
开发者ID:jedmao,项目名称:eclint,代码行数:9,代码来源:eclint.spec.ts

示例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);
	}
开发者ID:billwaddyjr,项目名称:gulp-typescript,代码行数:43,代码来源:project.ts

示例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 });
	}
开发者ID:dennari,项目名称:gulp-typescript,代码行数:12,代码来源:project.ts

示例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);
 });
开发者ID:valotas,项目名称:valotas.com,代码行数:13,代码来源:index.spec.ts


注:本文中的vinyl-fs.src函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。