Files
yarn/scripts/trim-mirror-test-packages.js
Simon Vocella 25890c8cf9 add prettier and prettying everything (#3401)
* add prettier and prettying everything

* fix scripts and run yarn prettier

* fix scripts again and run yarn prettier

* use eslint-plugin-prettify instead of custom scripts
2017-05-16 19:12:03 +01:00

34 lines
1014 B
JavaScript

'use strict';
/**
* For linking test purposes we may use a mirror of real life packages.
* This script goes through all packages in a mirror folder, strips anything
* that is not package.json because it is irrelevant to tests
*/
require('shelljs/global');
cd('__tests__/fixtures/install');
let files = ls('common-mirror-2');
cd('common-mirror-2');
for (let file of files) {
echo('repacking', file);
exec(`tar -xvzf ${file}`, {silent: true});
let folder = ls('').filter(
name => name.indexOf('.tgz') === -1 && name !== 'trimmed-package',
)[0];
mkdir('trimmed-package');
cp(`${folder}/package.json`, 'trimmed-package/package.json');
cd('trimmed-package');
let packageJson = JSON.parse(cat('package.json'));
// these sections have references to code and will fail installation
delete packageJson.scripts;
delete packageJson.bin;
JSON.stringify(packageJson, null, 4).to('package.json');
exec('yarn pack');
mv(file, '..');
cd('..');
rm('-rf', [folder, 'trimmed-package']);
}