Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.command('install', 'Install the html-sketchapp Sketch plugin', {}, async () => {
const { version } = require('@brainly/html-sketchapp/package.json');
console.log(`Detected html-sketchapp v${version}`);
const tmpDirPath = path.resolve(__dirname, '../', '.tmp');
const rimrafAsync = promisify(require('rimraf'));
await rimrafAsync(tmpDirPath);
await mkdirpAsync(tmpDirPath);
const [ major, minor, patch ] = version.split('.');
const releaseUrl = `http://github.com/brainly/html-sketchapp/releases/download/v${version}/asketch2sketch-${major}-${minor}-${patch}.sketchplugin.zip`;
console.log(`Downloading from ${releaseUrl}`);
const axios = require('axios');
const { data } = await axios(releaseUrl, { responseType: 'arraybuffer' });
console.log(`Extracting to ${tmpDirPath}`);
const decompress = require('decompress');
await decompress(data, tmpDirPath);
const pluginPath = path.resolve(tmpDirPath, 'asketch2sketch.sketchplugin');
console.log(`Installing from ${pluginPath}`);
const opn = require('opn');
opn(pluginPath, { wait: false });
})
.parse();