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

160
Views
Getting a file in multiple directories with matching filenames using javascript

I need to get a file named 'index.js' in multiple directories inside the repo and export the conditions inside 'index.js' into another file named 'functions.log'. This 'index.js' file can only be found inside '/dist' directory.

This is my initial script. There are more than 10 directories that have 'index.js' and the javascript file ('functions.js') is in the root folder outside of those 10.

functions.js

  const fs = require('fs');
  var directories = ['domain1/functions/dist', 'domain2/functions/dist', 'domain3/functions/dist', 'domain4/functions/dist', 'domain5/functions/dist'];
  const functions = require('index.js').join(__dirname, directories);
    
  const writeLog = fs.createWriteStream('./functions.log');
  writeLog.write(JSON.stringify(Object.keys(functions)));
about 4 years ago · Juan Pablo Isaza
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!