Skip to content

Commit

Permalink
Add .browserslistrc support (#96)
Browse files Browse the repository at this point in the history
* Add .browserslistrc update support

* Update tars-cli version

* Move logic of browserlistrc file update into separate function
  • Loading branch information
evilsprut authored and artem-malko committed Jan 14, 2019
1 parent 45f6c92 commit 44f6fc2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 21 deletions.
28 changes: 28 additions & 0 deletions lib/command-actions/update-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ function updateConfigFiles() {
* END update plugins-config.js
*/

/**
* START update .browserslistrc
*/
let downloadedBrowserslistrc;
let currentBrowserslistrc;

const updateBrowserslistrc = () => {
if (!fs.existsSync(`${cwd}/.browserslistrc`)) {
fsExtra.copySync(`${dest.tars.fullPath}/.browserslistrc`, `${cwd}/.browserslistrc`, { clobber: true });
return;
}

downloadedBrowserslistrc = fs.readFileSync(`${dest.tars.fullPath}/.browserslistrc`);
currentBrowserslistrc = fs.readFileSync(`${cwd}/.browserslistrc`);

if (downloadedBrowserslistrc !== currentBrowserslistrc) {
fsExtra.copySync(`${cwd}/.browserslistrc`, `${cwd}/${currentTarsVersion}-browserslistrc`, {clobber: true});
fsExtra.copySync(`${dest.tars.fullPath}/.browserslistrc`, `${cwd}/.browserslistrc`, { clobber: true });
}
};

if (semver.cmp(downloadedVersion, '>', '1.11.8')) {
updateBrowserslistrc();
}
/**
* END update .browserslistrc
*/

/**
* START tars-config.js update
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const commentJson = require('comment-json');
const semver = require('semver');

module.exports = function updatePluginsConfig(downloadedPluginsConfigString, currentPluginsConfigString, tarsConfig, currentTarsVersion) {
let parsedPluginsConfig = {};
Expand Down Expand Up @@ -31,6 +32,12 @@ module.exports = function updatePluginsConfig(downloadedPluginsConfigString, cur
parsedPluginsConfig['gulp-minify-html'] = undefined; // eslint-disable-line no-undefined
}

if (semver.cmp(currentTarsVersion, '>', '1.11.7')) {
if (parsedPluginsConfig.autoprefixerConfig) {
delete parsedPluginsConfig.autoprefixerConfig;
}
}

parsedPluginsConfig = Object.assign(
parsedDownloadedPluginsConfig,
parsedPluginsConfig
Expand Down
92 changes: 73 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tars-cli",
"version": "1.10.7",
"version": "1.10.8",
"engines": {
"node": "^6.x.x"
},
Expand Down Expand Up @@ -34,7 +34,7 @@
"license": "MIT",
"dependencies": {
"@babel/core": "^7.1.5",
"autoprefixer": "^8.2.0",
"autoprefixer": "^9.4.4",
"babel-loader": "^8.0.4",
"browser-sync": "^2.26.3",
"chalk": "^1.1.3",
Expand Down

0 comments on commit 44f6fc2

Please sign in to comment.