Skip to content

Commit

Permalink
fix(text-field): updated dependency check test and added special case…
Browse files Browse the repository at this point in the history
… for text-field (#1860)
  • Loading branch information
moog16 authored Jan 3, 2018
1 parent 5a19695 commit 3061a61
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 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,11 +129,8 @@ function checkPkgDependencyAddedInMDCPackage() {
}

function checkCSSDependencyAddedInMDCPackage() {
const name = pkg.name.split('/')[1];
let nameMDC = pkg.name.replace('@material/', 'mdc-');
if (name === 'textfield') {
nameMDC = 'mdc-text-field';
}
const name = getPkgName();
const nameMDC = `mdc-${name}`;
if (CSS_WHITELIST.indexOf(name) === -1) {
const src = fs.readFileSync(path.join(process.env.PWD, MASTER_CSS_PATH), 'utf8');
const cssRules = cssom.parse(src).cssRules;
Expand All @@ -150,7 +147,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 +227,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;
}

0 comments on commit 3061a61

Please sign in to comment.