Skip to content

Commit 83f0d60

Browse files
committed
Add upgrade-patch script
1 parent 274de2b commit 83f0d60

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

gulpfile.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,42 @@ gulp.task('outdated', () => {
6868
${formatPackageUpgrades(validUpgrades)}`);
6969
});
7070
});
71+
72+
gulp.task('upgrade-patch', () => {
73+
const allUpgradesPromises = libraries.map(library =>
74+
getUpgradeVersions(library).then(upgrades =>
75+
Object.assign(library, { upgrades })
76+
)
77+
);
78+
79+
return Promise.all(allUpgradesPromises).then(allUpgrades => {
80+
const validUpgrades = allUpgrades.filter(({ upgrades }) =>
81+
upgrades.get('patch')
82+
);
83+
84+
if (validUpgrades.length === 0) {
85+
log.warn(`No patch upgrades to process`);
86+
87+
return;
88+
}
89+
90+
validUpgrades.forEach(({ name, version, upgrades }) => {
91+
const patchVersion = upgrades.get('patch');
92+
log(`Upgrading ${name} from ${version} to ${patchVersion}`);
93+
94+
const eos = require('end-of-stream');
95+
const { spawn } = require('child_process');
96+
eos(
97+
spawn('yarn', ['upgrade', `${name}@${patchVersion}`]),
98+
err =>
99+
err
100+
? log.error(err)
101+
: spawn('git', [
102+
'commit',
103+
'-am',
104+
`Upgraded ${name} from ${version} to ${patchVersion}`,
105+
])
106+
);
107+
});
108+
});
109+
});

0 commit comments

Comments
 (0)