Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.onFinalize(async (object, event) => {
const bucket = gcs.bucket(object.bucket);
const filePath = object.name;
const fileName = filePath.split('/').pop();
const bucketDir = dirname(filePath);
const workingDir = join(tmpdir(), 'c0mpre$$ed');
const tmpFilePath = join(workingDir, 'source.png');
// We only want to compress if the request included a desire quality so we gather that here
const imageQuality = object.metadata ? object.metadata.quality : null;
console.log('event', event);
// bail if there isn't a quality passed from req or if the file has already been created or it's not an image
if ( !imageQuality || fileName.includes('c0mpre$$ed@') || !object.contentType.includes('image')) {
console.log('exiting function');
return false;
}
object.metadata.location = 'some new location';
console.log('metadata', object.metadata);
// 1. Ensure c0mpre$$ed dir exists
await fs.ensureDir(workingDir);
acceptedRawExtensions: [ 'raf', 'cr2', 'arw', 'dng' ],
acceptedNonRawExtensions: [ 'png', 'jpg', 'jpeg', 'tif', 'tiff', 'webp' ],
watchedFormats: /([$#\w\d]+)-([$#\w\dèé]+)-(\d+)\.(JPEG|JPG|PNG|PPM|TIFF|WEBP)/i,
workExt: 'webp' as PhotoRenderFormat,
/** The home directory of version 1.0.0 and before (where Picturama's name was Ansel) */
anselHomeDir,
picturamaHomeDir,
menusFolder,
keymapsFolder: `${picturamaAppDir}/keymaps`,
menuPath: `${menusFolder}/${platform}.json`,
dbFile: `${picturamaHomeDir}/db.sqlite3`,
dbMigrationsFolder: `${picturamaAppDir}/migrations`,
settings: `${picturamaHomeDir}/settings.json`,
nonRawPath: `${picturamaHomeDir}/non-raw`,
thumbnailPath: `${picturamaHomeDir}/thumbnails`,
tmp: `${os.tmpdir()}/picturama`,
concurrency: 3,
// TODO: Revive Legacy code of 'version' feature
/*
editors: [
{
name: 'Gimp',
cmd: 'gimp',
format: 'JPG',
platforms: [ 'darwin', 'linux' ]
},
{
name: 'Rawtherapee',
cmd: 'rawtherapee',
format: 'RAW',
platforms: [ 'darwin', 'linux' ]
'use strict';
const electron = require('electron');
const { clipboard } = require('electron');
const BrowserWindow = electron.remote.BrowserWindow;
const ipcRenderer = electron.ipcRenderer;
const winston = require('winston');
const xdgBasedir = require('xdg-basedir');
const os = require('os');
const path = require('path');
const configDir = path.join(xdgBasedir.config || path.join(os.tmpdir(), '.config'), 'freeshare');
let fileArray = null;
angular.module('free-share', ['ngRoute', 'angularSpinner', 'monospaced.qrcode'])
.controller('LoadingController', ($scope, $route, $routeParams, $location) => {
ipcRenderer.once('bootstrap', function (event) {
let bootstrapWin = new BrowserWindow({ width: 600, height: 300, alwaysOnTop: true, icon: __dirname + '/icon.ico' });
// bootstrapWin.webContents.openDevTools();
bootstrapWin.loadURL('file://' + __dirname + '/bootstrap.html');
let configged = false;
bootstrapWin.on('closed', () => {
bootstrapWin = null;
if (configged === true) {
ipcRenderer.send('start-file-server');
function _getDefaultDatabaseLocation() {
let location = path.join(os.tmpdir());
if (!isElectronRenderer) {
try {
// This module is only available inside 'Electron' main process
const app = require('app'); // eslint-disable-line
location = path.join(app.getPath('userData'), 'database2');
} catch (error) { /* no-op */ }
}
return location;
}
function test(description, func) {
const tmpDirPath = os.tmpdir() + '/knex-test-';
let itFails = false;
rimrafSync(tmpDirPath);
const tempFolder = fs.mkdtempSync(tmpDirPath);
fs.mkdirSync(tempFolder + '/migrations');
desc(description);
const taskName = description.replace(/[^a-z0-9]/g, '');
taskList.push(taskName);
task(taskName, { async: true }, () =>
func(tempFolder)
.then(() => console.log('☑ ' + description))
.catch((err) => {
console.log('☒ ' + err.message);
itFails = true;
})
.then(() => {
jake.exec(`rm -r ${tempFolder}`);
test('fs: adder', function (t) {
t.plan(4)
var id = String(Math.random()).substring(2)
var dir = path.join(tmp(), 'hyperdb-index-test-' + id)
var db = hyperdb(dir, { valueEncoding: 'json' })
var sum = 0
var version = null
var idx = index(db, {
processFn: function (node, next) {
if (typeof node.value === 'number') sum += node.value
next()
},
getVersion: function (cb) {
setTimeout(function () { cb(null, version) }, 50)
},
setVersion: function (s, cb) {
setTimeout(function () { version = s; cb(null) }, 50)
}
export function getTempDirectory(): string {
return tl.getVariable('agent.tempDirectory') || os.tmpdir();
}
'use strict';
var fs = require('fs');
var path = require('path');
var os = require('os');
var mkdir = require('mkdirp');
var chalk = require('chalk');
var exec = require('child_process').exec;
var which = require('which');
var tar = require('tar');
var zlib = require('zlib');
var request = require('request').defaults({
proxy: process.env.http_proxy || process.env.HTTP_PROXY ||
process.env.https_proxy || process.env.HTTPS_PROXY || ''
});
var progress = require('request-progress');
var tmpdir = os.tmpdir ? os.tmpdir() : os.tmpDir();
var util = module.exports;
util.fetch = function (url, dest, cb) {
cb = cb || function () {};
if (!fs.existsSync(path.dirname(dest))) {
mkdir.sync(path.dirname(dest));
}
return progress(request.get(url))
.on('response', function (resp) {
var status = resp.statusCode;
if (status < 200 || status > 300) {
return cb(new Error('Status code ' + status));
}
private async _install(npm: string, def: string, info: Info, onMessage: (msg: string) => void): Promise {
const filepath = path.join(os.tmpdir(), `${info.name}-`)
if (!fs.existsSync(path.dirname(filepath))) {
fs.mkdirSync(path.dirname(filepath))
}
let tmpFolder = await promisify(fs.mkdtemp)(filepath)
let url = info['dist.tarball']
onMessage(`Downloading from ${url}`)
await download(url, { dest: tmpFolder })
let content = await promisify(fs.readFile)(path.join(tmpFolder, 'package.json'), 'utf8')
let { dependencies } = JSON.parse(content)
if (dependencies && Object.keys(dependencies).length) {
onMessage(`Installing dependencies.`)
let p = new Promise((resolve, reject) => {
let args = ['install', '--ignore-scripts', '--no-lockfile', '--no-bin-links', '--production']
if (info['dist.tarball'] && info['dist.tarball'].includes('github.com')) {
args = ['install']
}