Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = context => {
// grab ~/.irapp/overrides
const overrideDir = jetpack.path(`${homeDir}`, '.irapp', 'overrides');
// grab the environment var
const envDir = process.env.IR_APP_PLUGIN_PATH || '';
// sanitize & verify they exist
return pipe(
split(';'),
map(trim),
prepend(overrideDir),
without(['', null]),
uniq,
filter(jetpack.exists)
)(envDir);
};
.then(() => {
// Key 'abc' hashed with sha1: 'a9993e364706816aba3e25717850c26c9cd0d89d'
const path = jetpack.path(testDir, 'a9', '993e364706816aba3e25717850c26c9cd0d89d');
expect(jetpack.exists(path)).toBe('file');
done();
});
});
const pkg = jetpack.path(directory, 'package.json')
// if we find a package.json, we're done -- read the version and return it
if (jetpack.exists(pkg) === 'file') {
return jetpack.read(pkg, 'json').version
}
// if we reach the git repo or root, we can't determine the version -- this is where we bail
const git = jetpack.path(directory, '.git')
const root = jetpack.path('/')
if (directory === root || jetpack.exists(git) === 'dir') {
break
}
// go up another directory
directory = jetpack.path(directory, '..')
}
throw new Error(`getVersion: Unknown CLI version (no package.json found in ${directory}`)
}
let directory = toolbox.runtime.defaultPlugin && toolbox.runtime.defaultPlugin.directory
if (!directory) {
throw new Error('getVersion: Unknown CLI version (no src folder found)')
}
// go at most 5 directories up to find the package.json
for (let i = 0; i < 5; i += 1) {
const pkg = jetpack.path(directory, 'package.json')
// if we find a package.json, we're done -- read the version and return it
if (jetpack.exists(pkg) === 'file') {
return jetpack.read(pkg, 'json').version
}
// if we reach the git repo or root, we can't determine the version -- this is where we bail
const git = jetpack.path(directory, '.git')
const root = jetpack.path('/')
if (directory === root || jetpack.exists(git) === 'dir') {
break
}
// go up another directory
directory = jetpack.path(directory, '..')
}
throw new Error(`getVersion: Unknown CLI version (no package.json found in ${directory}`)
}
export function getVersion(toolbox: IToolbox): string {
let directory = toolbox.runtime.defaultPlugin && toolbox.runtime.defaultPlugin.directory
if (!directory) {
throw new Error('getVersion: Unknown CLI version (no src folder found)')
}
// go at most 5 directories up to find the package.json
for (let i = 0; i < 5; i += 1) {
const pkg = jetpack.path(directory, 'package.json')
// if we find a package.json, we're done -- read the version and return it
if (jetpack.exists(pkg) === 'file') {
return jetpack.read(pkg, 'json').version
}
// if we reach the git repo or root, we can't determine the version -- this is where we bail
const git = jetpack.path(directory, '.git')
const root = jetpack.path('/')
if (directory === root || jetpack.exists(git) === 'dir') {
break
}
// go up another directory
directory = jetpack.path(directory, '..')
}
const listNextSubdir = () => {
if (this._subdirsToGo.length === 0) {
// No more directories to list!
deferred.reject('endOfPaths');
} else {
const subdir = this._subdirsToGo.pop();
const path = jetpack.path(this._basePath, subdir);
jetpack.listAsync(path)
.then((filenames) => {
// Generate absolute paths from filenames.
this._pathsToGive = filenames.map((filename) => {
return jetpack.path(path, filename);
});
if (this._pathsToGive.length > 0) {
// Yep. We have paths. Done!
deferred.resolve();
} else {
// This directory was apparently empty. Go for next one.
listNextSubdir();
}
});
}
};
allowReserved: true,
},
plugins: [
babel({
exclude: 'node_modules/**',
}),
replace({
delimiters: ['@{', '}'],
values: {
VERSION: manifest.version,
},
}),
inject({
exclude: 'node_modules/**',
modules: {
envGetter: jetpack.path(`config/env_${envName}.js`),
},
}),
nodeResolve(),
commonJs(),
uglify({
output: {
// Leave topmost comment with version
comments: (node, comment) => comment.line === 1,
},
}),
],
targets: [
{
dest: 'dist_cdn/filestack.js',
format: 'umd',
banner: `/* v${manifest.version} */`,
hosts = {};
oldHosts.forEach(function(item) {
item = item.replace(/\/$/, '');
hosts[item] = {
title: item,
url: item,
};
});
localStorage.setItem(this.hostsKey, JSON.stringify(hosts));
}
// Load server info from server config file
if (Object.keys(hosts).length === 0) {
const { app } = remote;
const userDir = jetpack.cwd(app.getPath('userData'));
const appDir = jetpack.cwd(jetpack.path(app.getAppPath(), app.getAppPath().endsWith('.asar') ? '..' : '.'));
const path = (userDir.find({ matching: 'servers.json', recursive: false })[0] && userDir.path('servers.json'))
|| (appDir.find({ matching: 'servers.json', recursive: false })[0] && appDir.path('servers.json'));
if (path) {
try {
const result = jetpack.read(path, 'json');
if (result) {
hosts = {};
Object.keys(result).forEach((title) => {
const url = result[title];
hosts[url] = { title, url };
});
localStorage.setItem(this.hostsKey, JSON.stringify(hosts));
// Assume user doesn't want sidebar if they only have one server
if (Object.keys(hosts).length === 1) {
localStorage.setItem('sidebar-closed', 'true');
const createWillDownloadHandler = (dispatch, runSaga) => (event, item) => {
const id = uniqid();
// TODO: fix download file overwrite
item.setSavePath(jetpack.path(app.getPath('downloads'), item.getFilename()));
item.on('updated', () => {
dispatch(downloadUpdated(createDownloadItem(id, item)));
});
item.once('done', () => {
if (item.getState() === 'cancelled') {
return;
}
dispatch(downloadUpdated(createDownloadItem(id, item)));
});
runSaga(function* handleClearDownload() {
for (;;) {
const { payload: _id } = yield take(DOWNLOAD_CLEARED);
if (id !== _id || item.isDestroyed()) {