require.js 444 B

12345678910111213
  1. var fs = require('fs')
  2. var path = require('path')
  3. var compile = require('./')
  4. delete require.cache[require.resolve(__filename)]
  5. module.exports = function(file, opts) {
  6. file = path.join(path.dirname(module.parent.filename), file)
  7. if (!fs.existsSync(file) && fs.existsSync(file+'.schema')) file += '.schema'
  8. if (!fs.existsSync(file) && fs.existsSync(file+'.json')) file += '.json'
  9. return compile(fs.readFileSync(file, 'utf-8'), opts)
  10. }