Sha256: 265104ae6f1d5a4adb254115b553a3b13a2b5e2296971db288c6745ab720d695

Contents?: true

Size: 827 Bytes

Versions: 20

Compression:

Stored size: 827 Bytes

Contents

var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('./mkdir')

function outputFile (file, data, encoding, callback) {
  if (typeof encoding === 'function') {
    callback = encoding
    encoding = 'utf8'
  }

  var dir = path.dirname(file)
  fs.exists(dir, function(itDoes) {
    if (itDoes) return fs.writeFile(file, data, encoding, callback)
    
    mkdir.mkdirs(dir, function(err) {
      if (err) return callback(err)
      
      fs.writeFile(file, data, encoding, callback)
    })
  })
}

function outputFileSync (file, data, encoding) {
  var dir = path.dirname(file)
  if (fs.existsSync(dir)) 
    return fs.writeFileSync.apply(fs, arguments)
  mkdir.mkdirsSync(dir)
  fs.writeFileSync.apply(fs, arguments)
}

module.exports = {
  outputFile: outputFile,
  outputFileSync: outputFileSync
}

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
gulp_assets-1.0.0.pre.5 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/output.js
gulp_assets-1.0.0.pre.4 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/output.js
gulp_assets-1.0.0.pre.3 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/output.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/output.js