Files
react-slot-fill/script/prepublish.js
Cameron Westland e598672882 update to support TypeScript 2.3.0 and React 15.5.x
Also emitting es2015 module version
2017-04-21 11:43:11 -07:00

65 lines
1.3 KiB
JavaScript

/* eslint-env shelljs */
require('shelljs/global');
const path = require('path');
/**
* Clean lib directory
*/
if (test('-e', path.join(__dirname, '..', 'lib'))) {
console.log('Cleaning lib');
rm('-rf', path.join(__dirname, '..', 'lib'));
}
/**
* Run rollup
*/
exec('rollup -c', { silent: false });
console.log('Building lib');
/**
* Run TypeScript
*/
exec('tsc', { silent: true });
console.log('Generating .d.ts files');
/**
* Copy .d.ts files into lib
*/
const r = path.join(__dirname, '..', 'build', 'dist')
const directories = new Set();
const files = new Map();
ls(path.join(__dirname, '..', 'build', 'dist', 'lib', '**', '*.d.ts')).forEach(source => {
const destination = path.join(__dirname, '..', path.relative(r, source));
// Guard copying test directories to lib
if (path.dirname(destination).includes('__tests__')) {
return;
}
const directory = path.dirname(destination);
if (!test('-e', directory)) {
// Create directory
directories.add(path.dirname(destination));
}
// Create these files
files.set(source, destination);
});
if (Array.from(directories).length !== 0) {
for (let directory of directories) {
mkdir('-p', directory);
}
}
for (let source of files.keys()) {
const destination = files.get(source);
cp(source, destination);
}