Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function(next){
fs.exists(pluginDir, function(exist){
if (exist){
next();
} else {
callback();
}
});
},
function(next){
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)
})
})
}
config.restoreUserReadme(function(err){
userConfig = config.getUserConfig();
l('templates located in '.green + userConfig.templatesPath);
//check if the template already exists
fs.exists( path.join(userConfig.templatesPath, template.name), function( exists ){
if( exists ){
//template is already installed, skip installing it
onComplete();
return;
}
//install amd-sketch template
sketchplate.installTemplate( userConfig, template.repo, template.name, function( err ){
l('installed '.green + template.repo + ' as template '.green + template.name );
onComplete();
});
l('fetching '.cyan + template.repo);
});
});
});
function onSourceShasums(err, shasums) {
if (err) {
return cb(err);
}
newShasums = shasums;
fs.exists(destination, onExists);
function onExists(exists) {
if (exists) {
shasumFiles(destination, onDestinationShasums);
} else {
onDestinationShasums(null, {});
}
}
}
function outputJson (file, data, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
var dir = path.dirname(file)
fs.exists(dir, function (itDoes) {
if (itDoes) return jsonFile.writeFile(file, data, options, callback)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
jsonFile.writeFile(file, data, options, callback)
})
})
}
return makePromise(function(callback) {
fs.exists(fullPath, function(exists) {
callback(null, exists);
});
});
};
fs.lstat(srcpath, function (err, stat) {
if (err) {
err.message = err.message.replace('lstat', 'ensureLink')
return callback(err)
}
var dir = path.dirname(dstpath)
fs.exists(dir, function (dirExists) {
if (dirExists) return makeLink(srcpath, dstpath)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
makeLink(srcpath, dstpath)
})
})
})
})
return new Promise(function (resolve) {
fs.exists(filename, function (exists) {
resolve(exists);
});
});
};
exists: function(path) {
var d = Q.defer();
fs.exists(path, d.resolve);
return d.promise;
},
readFileSync: fs.readFileSync.bind(fs)
return new Promise(resolve => {
return fs.exists(filename, resolve)
})
}