Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

684
Views
Gulp: ¿Cómo leo el contenido del archivo en una variable?

Tengo una tarea de trago que necesita leer un archivo en una variable y luego usar su contenido como entrada para una función diferente que se ejecuta en los archivos en la canalización. ¿Cómo puedo hacer eso?

Ejemplo psuedo-psuedo-código

 gulp.task('doSometing', function() { var fileContent=getFileContent("path/to/file.something"); //How? return gulp.src(dirs.src + '/templates/*.html') .pipe(myFunction(fileContent)) .pipe(gulp.dest('destination/path)); });
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Thargor me señaló en la dirección correcta:

 gulp.task('doSomething', function() { var fileContent = fs.readFileSync("path/to/file.something", "utf8"); return gulp.src(dirs.src + '/templates/*.html') .pipe(myFunction(fileContent)) .pipe(gulp.dest('destination/path')); });
over 4 years ago · Santiago Trujillo Report

0

¿Es esto lo que estás buscando?

 fs = require("fs"), gulp.task('doSometing', function() { return gulp.src(dirs.src + '/templates/*.html') .pipe(fs.readFile("path/to/file.something", "utf-8", function(err, _data) { //do something with your data })) .pipe(gulp.dest('destination/path')); });
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!