Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var file;
var oldPath;
var newPath;
// Remove any OS specific files from the files array
// before checking its length
files = files.filter(junk.isnt);
// Only rename if there's only one file and it's not the json
if (files.length === 1 && !/^(bower|component)\.json$/.test(files[0])) {
file = files[0];
this._singleFile = 'index' + path.extname(file);
oldPath = path.join(this._tempDir, file);
newPath = path.join(this._tempDir, this._singleFile);
return Q.nfcall(fs.rename, oldPath, newPath);
}
}.bind(this));
};
}, function () {
// If it fails to read, invalidate the in memory
// cache for the source and delete the entry directory
var sourceId = path.basename(path.dirname(dir));
that._cache.del(sourceId);
return Q.nfcall(rimraf, dir);
});
});
var that = this;
that.filename = opts.filename;
that.filetype = path.extname(that.filename);
// Set working directories
that.rootDirectory = opts.root || 'export';
that.assetsDirectory = opts.assetsDirectory || 'assets';
that._projectName = path.basename(that.filename, that.filetype);
that._projectFolder = path.join(that.rootDirectory, that._projectName);
that._assetsFolder = path.join(that._projectFolder, that.assetsDirectory);
that._summaryFile = path.join(that._projectFolder, 'SUMMARY.md');
// Check that file exists
Q.nfcall(fs.stat, that.filename)
.then(function() {
// Pick a to-HTML converter
that.pickConverter(that.filetype.slice(1));
// Create folders
that.createDirectories()
.fin(function() {
// Actually convert to HTML
that.convert()
.then(function() {
that.extractFootnotes();
that.parseAndClean();
that.toMarkdown();
that.writeFiles();
});
});
}).then(function(runtime) {
repoUrl = _.findWhere(templates, {name: runtime}).url;
return Q.nfcall(initAVOSCloudSDK, _appId, false);
}).then(function(AV) {
console.log("正在创建项目 ...");
function loadWithSettings (settings) {
if (cachedSettings) {
throw new Error('Trying to initialize npm when settings have not been restored from a previous initialization.');
}
return Q.nfcall(npm.load, settings).then(function () {
for (var prop in settings) {
var currentValue = npm.config.get(prop);
var newValue = settings[prop];
if (currentValue !== newValue) {
cachedSettingsValues = cachedSettingsValues || {};
cachedSettings = cachedSettings || [];
cachedSettings.push(prop);
if (typeof currentValue !== 'undefined') {
cachedSettingsValues[prop] = currentValue;
}
npm.config.set(prop, newValue);
}
}
});
}
function getTemplates(templateDir)
{
return Q.nfcall(fs.readdir, templateDir).then(function (files)
{
return Q.all(files.map(function (file)
{
return getTemplateSource(file, templateDir);
}));
});
}
file: function(opt) {
return Q.nfcall(tmp.file.bind(tmp), opt).get(0);
},
dir: function() {
function bumpVersion(answers, increment) {
var command = [
'npm version',
answers.semver,
'-m',
'"'+ answers.message +'"'
].join(' ');
return Q.nfcall(exec, command);
}
/**
exports.loadAll = function (db, cb) {
return Q.nfcall(exports.loadConfig)
.then(function () {
return Q.nfcall(exports.loadFixedData, db);
})
.nodeify(cb)
;
};
function readAppMetadata() {
const manifestPath = path.resolve(process.cwd(), 'manifest.json');
const manifest = Q.nfcall(fs.readFile, manifestPath, 'utf8')['catch'](function() {
throw new Error('Couldn\'t find manifest.json file.');
});
return manifest;
}