Skip to content

Instantly share code, notes, and snippets.

View zzarcon's full-sized avatar
🦍
Generating legacy code

Hector Zarco zzarcon

🦍
Generating legacy code
View GitHub Profile
@zzarcon
zzarcon / demo.md
Created August 28, 2020 04:49
hehe

Title

runWhen([{
changedFiles: () => Promise.resolve(['app/index.js', 'app/components/header.jsx']),
glob: ['app/components/**'],
task(paths) {}
}])
const subprocess = exec(command, {
env: {...process.env, FORCE_COLOR: true}
});
const subprocess = exec(command);
subprocess.stdout.pipe(process.stdout);
subprocess.stderr.pipe(process.stdout);
subprocess.on('exit', code => process.exit(code));
// Inline await to get the the user changed files
const filesToMatch = changedFiles ? await changedFiles() : files;
// Example of a test
test('should run command if glob files matches', async () => {
await modifyFixtures();
const {stdout} = await run(`'["__fixtures__/**"]' 'echo fixtures changed'`);
expect(stdout.trim()).toEqual('fixtures changed');
await restoreFixtures();
install:
- git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
- cd $TRAVIS_REPO_SLUG
- git checkout -qf $TRAVIS_COMMIT
const {2: serializedGlob = "['**']", 3: command} = process.argv;
console.log(serializedGlob, command)
const {promisify} = require('util');
const exec = promisify(require('child_process').exec);
exec('git diff --name-only origin/master').then(({stdout}) => console.log(stdout))
import runWhen from 'run-when';
runWhen([
{
glob: ['app/components/index.js', 'app/__tests__/**'],
task(paths) {
console.log('This will be called!');
}
},
{
class ImgDimensions extends React.Component {
state = {width: 0, height: 0, errored: false};
constructor() {
this.onLoad = this.onLoad.bind(this);
this.onError = this.onError.bind(this);
}
onLoad({target: {height, width}}) {
this.setState({width, height});