Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getBowerLicenses() {
// first - check that this is even a bower project
var baseDir;
if (Array.isArray(options.baseDir)) {
baseDir = options.baseDir[0];
if (options.baseDir.length > 1) {
console.warn("Checking multiple directories is not yet supported for Bower projects.\n" +
"Checking only the first directory: " + baseDir);
}
}
if (!jetpack.exists(path.join(baseDir, 'bower.json'))) {
console.log('this does not look like a Bower project, skipping Bower checks.');
return [];
}
bower.config.cwd = baseDir;
var bowerComponentsDir = path.join(bower.config.cwd, bower.config.directory);
return jetpack.inspectTreeAsync(bowerComponentsDir, { relativePath: true })
.then((result) => {
/**
* for each component, try to calculate the license from the NPM package info
* if it is a available because license-checker more closely aligns with our
* objective.
*/
return bluebird.map(result.children, (component) => {
var absPath = path.join(bowerComponentsDir, component.relativePath);
// npm license check didn't work
}
else if (jetpack.exists(oldZip) == false) {
if (vm.Message.showDebug()) vm.$log.debug(oldZip + ' is not in project.');
}
else {
vm.$log.error('jetpack.exists(' + oldZip + ') generated an unhandled return.');
}
if (jetpack.exists(oldJson) == 'file') {
if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is in project, and is being renamed to ' + newJson + '.');
jetpack.rename(oldJson, newJson);
}
else if (jetpack.exists(oldJson) == 'dir') {
vm.$log.error(oldJson + ' is a directory, and not a file.');
}
else if (jetpack.exists(oldJson) == 'other') {
vm.$log.error(oldJson + ' is an unknown type.');
}
else if (jetpack.exists(oldJson) == false) {
if (vm.Message.showDebug()) vm.$log.debug(oldJson + ' is not in project.');
}
else {
vm.$log.error('jetpack.exists(' + oldJson + ') generated an unhandled return.');
}
// set project Variables
vm.setProjectVariables(projectDir);
vm.$translate('toastr.projectSaved').then(translation => {
vm.toastr.success(translation);
});
vm.$state.transitionTo('analysis', {}, {reload: true});
async function migrate() {
const olderAppName = 'Rocket.Chat+';
const dirName = process.env.NODE_ENV === 'production' ? olderAppName : `${ olderAppName } (${ process.env.NODE_ENV })`;
const olderUserDataPath = path.join(app.getPath('appData'), dirName);
try {
await jetpack.copyAsync(olderUserDataPath, app.getPath('userData'), { overwrite: true });
await jetpack.removeAsync(olderUserDataPath);
} catch (error) {
if (jetpack.exists(olderUserDataPath)) {
throw error;
}
console.log('No data to migrate.');
}
}
return bluebird.map(keys, (key) => {
console.log('processing', key);
var package = result[key];
var defaultPackagePath = `${package['dir']}/node_modules/${package.name}/package.json`;
var itemAtPath = jetpack.exists(defaultPackagePath);
var packagePath = [defaultPackagePath];
if (itemAtPath !== 'file') {
packagePath = jetpack.find(package['dir'], {
matching: `**/node_modules/${package.name}/package.json`
});
}
var packageJson = "";
if (packagePath && packagePath[0]) {
packageJson = jetpack.read(packagePath[0], 'json');
} else {
return Promise.reject(`${package.name}: unable to locate package.json`);
}
let load = function(path) {
if (!jetpack.exists(path)) console.log(`ERROR: File not found at "${path}"`);
let code = ensureTrailingNewLine(jetpack.read(path));
const magicStr = new MagicString(code);
concatFiles(magicStr, code, path);
return magicStr.toString();
};
function isDirectory(path: string): boolean {
return jetpack.exists(path) === 'dir'
}
createOrReadDatabase (db) {
const dirName = process.env.NODE_ENV === 'development' ? '.rss-reader-dev' : '.rss-reader'
const existsDir = jetpack.exists(this.useDataDir.path(dirName))
if (!existsDir) {
fs.mkdir(this.useDataDir.path(`${dirName}`), (err) => {
if (err) {}
})
}
const existsArticle = fs.existsSync(this.useDataDir.path(`${dirName}/${db.article}`))
const existsFeed = fs.existsSync(this.useDataDir.path(`${dirName}/${db.feed}`))
const existsCategory = fs.existsSync(this.useDataDir.path(`${dirName}/${db.category}`))
const database = {}
if (!existsArticle && !existsFeed && !existsCategory) {
this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.article}`), '')
this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.feed}`), '')
this.useDataDir.write(this.useDataDir.path(`${dirName}/${db.category}`), '')
}
export const migrateSettings = () => {
if (fs.exists(oldConfigPath)) {
const oldConfig = JSON.parse(fs.read(oldConfigPath));
Object.keys(oldConfig)
.forEach(key => {
settings.set(key, oldConfig[key]);
});
fs.remove(oldConfigPath);
}
};
function createWindow () {
/**
* If there is already data in old directory. Moved it to new
*/
const oldDirectory = jetpack.cwd(app.getPath('userData'))
const newDirectory = jetpack.cwd(app.getPath('home'))
const existsArticle = jetpack.exists(oldDirectory.path('articles.db'))
const existsFeed = jetpack.exists(oldDirectory.path('feeds.db'))
const winURL = process.env.NODE_ENV === 'development' ? 'http://localhost:9080' : `file://${__dirname}/index.html`
if (existsArticle && existsFeed) {
jetpack.move(oldDirectory.path('feeds.db'), newDirectory.path('.rss-reader/feeds.db'))
jetpack.move(oldDirectory.path('articles.db'), newDirectory.path('.rss-reader/articles.db'))
}
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
webPreferences: {
webviewTag: true,
nodeIntegration: true,
nodeIntegrationInWorker: true,
webSecurity: true
},
if (req.body.path !== req.path) {
throw new Error(
`Expected ${JSON.stringify(req.path)}, not ${JSON.stringify(
req.body.path
)}`
)
}
const filepath = path.join(
process.cwd(),
"routes",
req.path,
`index${extension}`
)
if (jetpack.exists(filepath)) {
throw new Error(`Route already exists at ${filepath}`)
}
const content = stripIndent(
extension.startsWith(".ts")
? `
import { Request, Response } from "express"
export default (req: Request, res: Response) => {
res.send("📝 ${req.path}")
}
`
: `
module.exports = (req, res) => {
res.send("📝 ${req.path}")
}