Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

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

Merged
merged 2 commits into from
Jan 3, 2018
Merged
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
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;
}