alykoshin / require-dir-all

Yet another Node.js helper to require all files in directory
MIT License
9 stars 1 forks source link

feature request: recursiveOneLevel #1

Open bjrmatos opened 8 years ago

bjrmatos commented 8 years ago

hi! will you accept a PR supporting a new feature -> recursiveOneLevel: true?

i have a directory

image

in services/index.js i'm calling:

module.exports = require('require-dir-all')('./', {
  recursive: true,
  indexAsParent: true
});

given me:

{
  ElectronicDocument: {
    validations: // exported value here,
    declareElectronicFormat: // exported value here,
    generateElectronicFormat: // exported value here,
    generatePrintedFormat: // exported value here,
    saveDocuments: // exported value here,
    sendPrintedFormatToCustomer: // exported value here,
    verifyUniqueEmission: // exported value here
  },

  EmissionCustomer: // exported value here,

  EmissionIssuer: // exported value here,

  ReceptionRecordService: // exported value here,

  SummaryDocument: // exported value here,

  VoidedDocument: // exported value here
}

however i only want the exported values of the first level subdirectories (subdirectory/index.js) inside services/, example:

{
  ElectronicDocument: {
    // no `validations` folder exported
    declareElectronicFormat: // exported value here,
    generateElectronicFormat: // exported value here,
    generatePrintedFormat: // exported value here,
    saveDocuments: // exported value here,
    sendPrintedFormatToCustomer: // exported value here,
    verifyUniqueEmission: // exported value here
  },

  EmissionCustomer: // exported value here,

  EmissionIssuer: // exported value here,

  ReceptionRecordService: // exported value here,

  SummaryDocument: // exported value here,

  VoidedDocument: // exported value here
}
alykoshin commented 8 years ago

Hi. The feature is absolutely reasonable. I can easily imagine other situations when it may be useful. But I'd prefer to make it more general.

This will be also easier to use and remember, I think, instead of having two params. What do you think?

bjrmatos commented 8 years ago

@alykoshin i agree :smile: , i'll start this feature and submit a PR!