Sha256: 25ec09ad12546cba82c7c64215eb71aff00914ef9cb95b4643f57f721bb3c01d
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
"use strict" var mkdir = require('./mkdir') , path = require('path') , fs = require('fs') , exists = fs.exists || path.exists , existsSync = fs.existsSync || path.existsSync function createFile (file, callback) { function makeFile() { fs.writeFile(file, '', function(err) { if (err) callback(err) else callback(null); }) } exists(file, function(fileExists) { if (fileExists) return callback(null); else { var dir = path.dirname(file); exists(dir, function(dirExists) { if (!dirExists) { mkdir.mkdirs(dir, function(err) { if (err) callback(err) else makeFile(); }) } else { makeFile(); } }) } }) } function createFileSync (file) { if (existsSync(file)) return; var dir = path.dirname(file); if (!existsSync(dir)) mkdir.mkdirsSync(dir); fs.writeFileSync(file, ''); } module.exports.createFile = createFile; module.exports.createFileSync = createFileSync;
Version data entries
2 entries across 2 versions & 1 rubygems