Skip to content
Snippets Groups Projects
Select Git revision
  • function_tracer
  • master default protected
  • dependabot/pip/idna-3.7
  • dependabot/pip/immutabledict-4.2.0
  • dependabot/pip/pillow-10.3.0
  • dependabot/pip/jinja2-3.1.3
  • dependabot/pip/gitpython-3.1.41
  • dependabot/pip/black-24.3.0
  • dependabot/github_actions/peaceiris/actions-gh-pages-4.0.0
  • dependabot/cargo/serde_json-1.0.116
  • dependabot/github_actions/actions/cache-4
  • dependabot/cargo/serde-1.0.198
  • dependabot/github_actions/peaceiris/actions-mdbook-2.0.0
  • dependabot/github_actions/dawidd6/action-download-artifact-3.1.4
  • dependabot/cargo/anyhow-1.0.82
  • dependabot/github_actions/JasonEtco/create-an-issue-2.9.2
  • dependabot/cargo/pyo3-0.20.3
  • dependabot/cargo/log-0.4.21
  • gh-pages
  • develop
  • clokep/morg-readme
  • v1.98.0
  • v1.98.0rc1
  • v1.97.0
  • v1.97.0rc1
  • v1.96.1
  • v1.96.0
  • v1.96.0rc1
  • v1.95.1
  • v1.95.0
  • v1.95.0rc1
  • v1.94.0
  • v1.94.0rc1
  • v1.93.0
  • v1.93.0rc1
  • v1.92.3
  • v1.92.2
  • v1.92.1
  • v1.92.0
  • v1.91.2
  • v1.92.0rc1
41 results

pylint.cfg

Blame
  • yarn.js 2.44 KiB
    const fs = require('fs-extra');
    const path = require('path');
    const { getInstalledPath } = require('get-installed-path');
    const { exec } = require('child-process-promise');
    
    module.exports = {
      generateLockFile,
    };
    
    async function generateLockFile(tmpDir) {
      logger.debug(`Spawning yarn install to create ${tmpDir}/yarn.lock`);
      let lockFile = null;
      let stdout;
      let stderr;
      try {
        const startTime = process.hrtime();
        let cmd;
        try {
          // See if renovate is installed locally
          const installedPath = path.join(
            await getInstalledPath('yarn', {
              local: true,
            }),
            'bin/yarn.js'
          );
          cmd = `node ${installedPath}`;
        } catch (localerr) {
          logger.debug('No locally installed yarn found');
          // Look inside globally installed renovate
          try {
            const renovateLocation = await getInstalledPath('renovate');
            const installedPath = path.join(
              await getInstalledPath('yarn', {
                local: true,
                cwd: renovateLocation,
              }),
              'bin/yarn.js'
            );
            cmd = `node ${installedPath}`;
          } catch (nestederr) {
            logger.debug('Could not find globally nested yarn');
            // look for global yarn
            try {
              const installedPath = path.join(
                await getInstalledPath('yarn'),
                'bin/yarn.js'
              );
              cmd = `node ${installedPath}`;
            } catch (globalerr) {
              logger.warn('Could not find globally installed yarn');
              cmd = 'yarn';
            }
          }
        }
        logger.debug(`Using yarn: ${cmd}`);
        cmd += ' install';
        cmd += ' --ignore-scripts';
        cmd += ' --ignore-engines';
        // TODO: Switch to native util.promisify once using only node 8
        ({ stdout, stderr } = await exec(cmd, {
          cwd: tmpDir,
          shell: true,
          env: { NODE_ENV: 'dev', PATH: process.env.PATH },
        }));
        logger.debug(`yarn stdout:\n${stdout}`);
        logger.debug(`yarn stderr:\n${stderr}`);
        const duration = process.hrtime(startTime);
        const seconds = Math.round(duration[0] + duration[1] / 1e9);
        lockFile = await fs.readFile(path.join(tmpDir, 'yarn.lock'), 'utf8');
        logger.info(
          { seconds, type: 'yarn.lock', stdout, stderr },
          'Generated lockfile'
        );
      } catch (err) /* istanbul ignore next */ {
        logger.info(
          {
            err,
          },
          'yarn install error'
        );
        return { error: true, stderr: err.stderr };
      }
      return { lockFile };
    }