Skip to content

Instantly share code, notes, and snippets.

@mryechkin
Last active August 22, 2022 13:36
Show Gist options
  • Save mryechkin/a80a22bb2651bde70c9aa2fb4d925bc5 to your computer and use it in GitHub Desktop.
Save mryechkin/a80a22bb2651bde70c9aa2fb4d925bc5 to your computer and use it in GitHub Desktop.

Revisions

  1. mryechkin revised this gist Aug 21, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dependencies.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ if (dependencies && dependencies.length) {
    const filteredList = ['@wtf-ds/core', 'react', 'styled-components'];

    promises = filteredList.map(async (name) => {
    const { stdout } = await exec(`npm list --depth=0 ${name}`);
    const { stdout } = await exec(`npm list --depth=0 ${name} | grep ${name}`);

    const idx = stdout.indexOf(name);
    const version = stdout.substring(idx + name.length + 1).replace('\n', '');
  2. mryechkin created this gist Aug 20, 2022.
    27 changes: 27 additions & 0 deletions dependencies.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    const fs = require('fs');
    const util = require('util');
    const exec = util.promisify(require('child_process').exec);

    const package = require('../package.json');

    const dependencies = Object.keys(packageData.dependencies).map((dep) => dep);

    let promises = [];

    if (dependencies && dependencies.length) {
    const filteredList = ['@wtf-ds/core', 'react', 'styled-components'];

    promises = filteredList.map(async (name) => {
    const { stdout } = await exec(`npm list --depth=0 ${name}`);

    const idx = stdout.indexOf(name);
    const version = stdout.substring(idx + name.length + 1).replace('\n', '');

    return { name, version };
    });
    }

    Promise.all(promises).then((result) => {
    const data = JSON.stringify(result, null, 2);
    fs.writeFileSync('dependencies.json', data);
    });