Sha256: 032406ce58ac9ab742dc64eecae208e20aad0730e7d2d88a26fee9bd2ae084b4

Contents?: true

Size: 840 Bytes

Versions: 20

Compression:

Stored size: 840 Bytes

Contents

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

function createFile (file, callback) {
  function makeFile() {
    fs.writeFile(file, '', function(err) {
      if (err) return callback(err)
      callback()
    })
  }

  fs.exists(file, function(fileExists) {
    if (fileExists) return callback()
    var dir = path.dirname(file)
    fs.exists(dir, function(dirExists) {
      if (dirExists) return makeFile()
      mkdir.mkdirs(dir, function(err) {
        if (err) return callback(err)
        makeFile()
      })
    })
  })
}

function createFileSync (file) {
  if (fs.existsSync(file)) return

  var dir = path.dirname(file)
  if (!fs.existsSync(dir))
    mkdir.mkdirsSync(dir)

  fs.writeFileSync(file, '')
}

module.exports = {
  createFile: createFile,
  createFileSync: createFileSync
}

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/create.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
gulp_assets-1.0.0.pre.5 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/create.js
gulp_assets-1.0.0.pre.4 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/create.js
gulp_assets-1.0.0.pre.3 template/node_modules/css-mqpacker/node_modules/fs-extra/lib/create.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.13 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.12 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.11 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js
entangled-0.0.10 spec/dummy/public/node_modules/phantomjs/node_modules/fs-extra/lib/create.js