Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .browserslistrc support #96

Merged
merged 3 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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