當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。