Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Compare webpack.config files #485

Merged
merged 2 commits into from
Apr 5, 2018
Merged

Compare webpack.config files #485

merged 2 commits into from
Apr 5, 2018

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Apr 4, 2018

Compare current webpack.config.js and the one that will come from the installing version of nativescript-dev-webpack plugin and in case when they are different print a warning message.

PR Checklist

What is the current behavior?

When the user has a project with already generated webpack.config.js and update nativescript-dev-webpack plugin to newer version, webpack.config.js is not replaced and this way if the newer version of nativescript-dev-webpack has changes in webpack.config.js file they are not respected in user project.

What is the new behavior?

When the user has a project with already generated webpack.config.js and update nativescript-dev-webpack plugin to newer version which has changes in webpack.config.js file, a warning message if printed to ask the user to manually update the file.

… installing version of nativescript-dev-webpack plugin and in case when they are different print a warning message.
const newTemplate = fs.readFileSync(newTemplatePath).toString();
if (newTemplate !== currentTemplate) {
const message = `The current project contains a ${path.basename(currentTemplatePath)} file located at ${currentTemplatePath} that differs from the one in the new version of the nativescript-dev-webpack plugin located at ${newTemplatePath}. Some of the plugin features may not work as expected until you manually update the ${path.basename(currentTemplatePath)} file.`;
console.info(`\x1B[33;1m${message}\x1B[0m` );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developers can also use this script to overwrite the existing configuration files:

./node_modules/.bin/update-ns-webpack --configs

Copy link
Contributor

@rosen-vladimirov rosen-vladimirov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after handling comment

@@ -37,6 +37,21 @@ function forceUpdateProjectFiles(projectDir, appDir) {
addProjectFiles(projectDir, appDir);
}

function compareProjectFiles(projectDir) {
const projectTemplates = getProjectTemplates(projectDir);
Object.keys(projectTemplates).forEach(function(newTemplatePath){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use lamda syntax here:

 Object.keys(projectTemplates).forEach( newTemplatePath => {

@Fatme
Copy link
Contributor Author

Fatme commented Apr 5, 2018

run ci

@SvetoslavTsenov
Copy link
Contributor

test

@Fatme Fatme merged commit d917b65 into master Apr 5, 2018
@Fatme Fatme deleted the fatme/compare-configs branch April 5, 2018 08:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants