Comparing version 1.1.0 to 1.2.0
47
index.js
@@ -6,5 +6,6 @@ const increment = require('semver').inc; | ||
const packageDirectories = ['content', 'etc']; | ||
const excludedDirs = ['node_modules']; | ||
const themesPath = 'etc/designs/zg'; | ||
const themeInfoName = 'theme.json'; | ||
const themeContents = ['desktop', themeInfoName] | ||
@@ -15,6 +16,2 @@ const isDirectory = (source) => { | ||
const isPackageRoot = (source) => { | ||
return diff(packageDirectories, getDirectories(source).map(dir => getName(dir))).length === 0; | ||
} | ||
const getDirectories = (source) => { | ||
@@ -24,10 +21,41 @@ return readdirSync(source).map(name => join(source, name)).filter(isDirectory); | ||
const isTheme = (source) => { | ||
const contents = readdirSync(source); | ||
return diff(contents, themeContents).length === 0; | ||
} | ||
const getThemes = (source) => { | ||
const path = join(source, themesPath); | ||
if (!existsSync(path)) return []; | ||
return getDirectories(join(source, themesPath)); | ||
}; | ||
let themes = []; | ||
if (!existsSync(source)) { | ||
throw new Error('Not existing directory'); | ||
return; | ||
} | ||
if (isDirectory(source) && isTheme(source)) { | ||
themes.push(source); | ||
} else { | ||
readdirSync(source).forEach((file) => { | ||
const filename = join(source, file); | ||
if (file.startsWith('.') || excludedDirs.indexOf(file) > -1) { | ||
return false; | ||
} | ||
if (isDirectory(filename)) { | ||
if (isTheme(filename)) { | ||
themes.push(filename); | ||
} else { | ||
themes = themes.concat(getThemes(filename)); | ||
} | ||
} | ||
}); | ||
} | ||
return themes; | ||
} | ||
const getThemeInfo = (source) => { | ||
const path = resolve(source, themeInfoName); | ||
if (!existsSync(path)) return {}; | ||
return require(path); | ||
@@ -42,3 +70,2 @@ }; | ||
if (!existsSync(root)) throw new Error('Not existing directory'); | ||
if (!isPackageRoot(root)) throw new Error('Directory is not a root of Creative Exchange package'); | ||
@@ -45,0 +72,0 @@ const themePaths = getThemes(root); |
{ | ||
"name": "theme-bump", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Bump the version of Zen Garden themes in Creative Exchange", | ||
@@ -5,0 +5,0 @@ "repository": "git://github.com/mateuszluczak/theme-bump.git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5709
104