This repository has been archived by the owner on Apr 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
The replace
property is not mandatory anymore (#57)
#86
Merged
StefanoMagrassi
merged 3 commits into
contactlab:develop
from
LasaleFamine:fix/57-replace-no-mandatory
May 25, 2017
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ class Kubozer { | |
|
||
replace() { | ||
this._ensureWorkspace(); | ||
|
||
const defaultOptions = {files: 'nothing', from: 'nothing', to: 'nothing'}; | ||
const optionCSS = {}; | ||
const optionJS = {}; | ||
|
||
|
@@ -133,14 +133,10 @@ class Kubozer { | |
}); | ||
} | ||
|
||
if (optionJS.files === undefined && optionCSS.files === undefined) { | ||
throw new Error('WARNING REPLACE(): replace method called but "files" not found in configuration'); | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
try { | ||
const changedCSS = replaceInFile.sync(optionCSS); | ||
const changedJS = replaceInFile.sync(optionJS); | ||
const changedCSS = replaceInFile.sync(optionCSS.files ? optionCSS : defaultOptions); | ||
const changedJS = replaceInFile.sync(optionJS.files ? optionJS : defaultOptions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LasaleFamine same as previous comment |
||
|
||
return resolve(success(REPLACE_COMPLETED, {changedCSS, changedJS})); | ||
} catch (err) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,18 @@ test('replace() products correct output', async t => { | |
t.is(fileReplace, `<!DOCTYPE html><html><head>\n <meta charset=\"utf-8\">\n <title></title>\n\n \n <link rel=\"stylesheet\" href=\"/assets/style.css\">\n \n\n \n <script src=\"/assets/javascript.js\"></script>\n \n\n </head>\n <body>\n\n \n\n</body></html>`); | ||
}); | ||
|
||
test('when running replace() the "replace" property of configuration is not mandatory', async t => { | ||
const {tmpDir, webpackConfig} = t.context; | ||
const config = hconf(tmpDir, ['FOLDERS', 'VULCANIZE_NO_JS', 'MANIFEST']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LasaleFamine maybe 'MANIFEST' configuration is useless here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now should be correct. |
||
const kubozer = new Kubozer(config, webpackConfig); | ||
|
||
const res = await kubozer.replace(); | ||
t.deepEqual(res.data.changedCSS, []); | ||
t.deepEqual(res.data.changedJS, []); | ||
t.is(res.message, 'Replace-in-file completed.'); | ||
t.is(res.error, undefined); | ||
}); | ||
|
||
test('correct bump() method', async t => { | ||
const {tmpDir, webpackConfig} = t.context; | ||
const config = hconf(tmpDir, ['FOLDERS', 'BUMP']); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LasaleFamine maybe you can use Ramda's merge method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discuss, we can introduce new logic (and libs) during the refactor.