How to use the @brainly/html-sketchapp/package.json.version.split function in @brainly/html-sketchapp

To help you get started, we’ve selected a few @brainly/html-sketchapp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seek-oss / html-sketchapp-cli / bin / cli.js View on Github external
.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();