Files
Dan Tamas dbf746d66c Unify eslint with react-community standard (#2862)
* move eslitnt rules to @react-native-community/eslint-config

* gitignore VSCode workspace settings

* update eslint related packages and remove airbnb ones

* add .prettierrc config

* automated fix by eslint and prettier

* remove custom eslint rules

* remove never reported elint exceptions

* remove unlimited eslint-disable exceptions

* fix  formating

* fix inline styles

* fix react to 16.8.3 and remove babel-preset-react-native
2019-05-15 15:08:19 +02:00

71 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* Script that runs as part of `npm version`. It updates any files that have a
* reference to the current package version:
*
* - gradle.properties
* x react-native-maps.podspec // <-- this is now dynamic
* x react-native-google-maps.podspec // <-- this is now dynamic
*
* And `git add`s them.
*/
const { exec } = require('child_process');
const pkg = require('../package.json');
const filesToUpdate = ['gradle.properties'];
function doExec(cmdString) {
return new Promise((resolve, reject) => {
exec(cmdString, (err, stdout) => {
if (err) {
reject(err);
return;
}
resolve(stdout);
});
});
}
function updateVersionInFile(currentVersion, nextVersion, relativePath) {
process.stdout.write(`• ${relativePath}\n`);
return doExec(
`sed -i '' 's/${escapeDots(currentVersion)}/${escapeDots(
nextVersion
)}/g' ./${relativePath}`
);
}
function escapeDots(version) {
return version.replace(/\./g, '\\.');
}
function run() {
const currentVersion = pkg.version;
const nextVersion = process.env.npm_package_version;
Promise.resolve()
.then(() => updateFiles(currentVersion, nextVersion))
.then(() => gitAdd());
}
// Tasks
function updateFiles(currentVersion, nextVersion) {
process.stdout.write(`Updating ${currentVersion} ➞ ${nextVersion}:\n`);
return Promise.all(
filesToUpdate.map(relativePath =>
updateVersionInFile(currentVersion, nextVersion, relativePath)
)
);
}
function gitAdd() {
return doExec(`git add ${filesToUpdate.join(' ')}`);
}
// Do it.
run();