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

fix(text-field): updated dependency check test and added special case… #1860

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Changes from 1 commit
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
20 changes: 15 additions & 5 deletions scripts/check-pkg-for-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function checkPublicConfigForNewComponent() {
}

function checkNameIsPresentInAllowedScope() {
const name = pkg.name.split('/')[1];
const name = getPkgName();
assert.notEqual(REPO_PKG.config['validate-commit-msg']['scope']['allowed'].indexOf(name), -1,
'FAILURE: Component ' + pkg.name + ' is not added to allowed scope. Please check package.json ' +
'and add ' + name + ' to config["validate-commit-msg"]["scope"]["allowed"] before commit.');
Expand Down Expand Up @@ -98,7 +98,7 @@ function checkJSDependencyAddedInWebpackConfig() {
}

function checkCSSDependencyAddedInWebpackConfig() {
const name = pkg.name.split('/')[1];
const name = getPkgName();
if (CSS_WHITELIST.indexOf(name) === -1) {
const cssconfig = WEBPACK_CONFIG.find((value) => {
return value.name === 'css';
Expand Down Expand Up @@ -129,9 +129,9 @@ function checkPkgDependencyAddedInMDCPackage() {
}

function checkCSSDependencyAddedInMDCPackage() {
const name = pkg.name.split('/')[1];
const name = getPkgName();
let nameMDC = pkg.name.replace('@material/', 'mdc-');
if (name === 'textfield') {
if (name === 'text-field') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this if statement at all anymore. 'mdc-' plus 'text-field' equals 'mdc-text-field'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the if condition and updated it to use name variable

nameMDC = 'mdc-text-field';
}
if (CSS_WHITELIST.indexOf(name) === -1) {
Expand All @@ -150,7 +150,7 @@ function checkCSSDependencyAddedInMDCPackage() {
function checkJSDependencyAddedInMDCPackage() {
const NOT_IMPORTED = ['animation'];
const NOT_AUTOINIT = ['auto-init', 'base', 'selection-control'];
const name = pkg.name.split('/')[1];
const name = getPkgName();
if (typeof(pkg.main) !== 'undefined' && NOT_IMPORTED.indexOf(name) === -1) {
const nameCamel = camelCase(pkg.name.replace('@material/', ''));
const src = fs.readFileSync(path.join(process.env.PWD, MASTER_JS_PATH), 'utf8');
Expand Down Expand Up @@ -230,3 +230,13 @@ function checkComponentExportedAddedInMDCPackage(ast) {
});
return isExported;
}

function getPkgName() {
let name = pkg.name.split('/')[1];
if (name === 'textfield') {
// Text-field now has a dash in the name. The package cannot be changed,
// since it is a lot of effort to rename npm package
name = 'text-field';
}
return name;
}