From e77cfb7e91fbc8157571b613ddb8f19966f953a1 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Wed, 2 Nov 2016 13:47:54 +0200 Subject: [PATCH] style: update scripts/ to follow the coding conventions --- scripts/builder.js | 8 ++-- scripts/postinstall.js | 20 +++++----- scripts/uninstall.js | 87 +++++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 59 deletions(-) diff --git a/scripts/builder.js b/scripts/builder.js index 9af998b..7c287be 100644 --- a/scripts/builder.js +++ b/scripts/builder.js @@ -40,7 +40,7 @@ copyFile("./nativescript-theme-core.json", "./nativescript-theme-core/package.js // Copy our Post Install Script copyFile("./scripts/postinstall.js", "./nativescript-theme-core/scripts/postinstall.js"); -// Copy our Un-install +// Copy our Un-install copyFile("./scripts/uninstall.js", "./nativescript-theme-core/scripts/uninstall.js"); // Copy our Readme @@ -113,7 +113,7 @@ function copySCSS() { fs.writeFileSync(out, scss, 'utf8'); } else { fs.writeFileSync(out, fs.readFileSync(sassFiles[i])); - } + } } } @@ -123,7 +123,7 @@ function copySCSS() { * Create all the CSS from SCSS files */ function createCSSFromSCSS() { - + var sassFilesPath = './app/**/*.scss'; var sassImportPaths = [ './app/', @@ -179,7 +179,7 @@ function parseSass(sassFile, importPaths) { // console.log(css); fs.writeFileSync(cssFilePath, css, 'utf8'); - // if build stats are ever desired + // if build stats are ever desired // console.log(result.stats); } }); diff --git a/scripts/postinstall.js b/scripts/postinstall.js index cd2058d..3f88bf0 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -44,7 +44,7 @@ copyFolder(cwd+"css", appDir+"css"); var appSheetPath = appDir + "app.css"; var themeBasePath = "~/css/core."; if (!themeImported(appSheetPath, themeBasePath)) { - var themePath = `@import "${themeBasePath}light.css";`; + var themePath = `@import '${themeBasePath}light.css';`; fs.appendFileSync(appSheetPath, os.EOL); fs.appendFileSync(appSheetPath, themePath); @@ -77,18 +77,18 @@ if (hasSCSS) { // ------------------------------------------------------- /** - * Checks whether a style sheet is imported in another sheet + * Checks whether a theme sheet is imported in another sheet * @param sheetPath (string) - The main sheet - * @param themePath (string) - The sheet to check whether imported + * @param themeBasePath (string) - The base name of the theme */ -function themeImported(sheetPath, themePath) { +function themeImported(sheetPath, themeBasePath) { if (!fs.existsSync(sheetPath)) { return false; } var cssData = fs.readFileSync(sheetPath).toString(); - return cssData.indexOf(`@import '${themePath}`) !== -1 || - cssData.indexOf(`@import "${themePath}`) !== -1; + return cssData.indexOf(`@import '${themeBasePath}`) !== -1 || + cssData.indexOf(`@import "${themeBasePath}`) !== -1; } /** @@ -152,20 +152,18 @@ function checkIfTNSBug() { // Windows & Linux var env = process.env["TMP"]; if (env && process.argv[1].indexOf(env) === 0) { - process.exit(0); + process.exit(0); } // Windows & Linux env = process.env["TEMP"]; if (env && process.argv[1].indexOf(env) === 0) { - process.exit(0); + process.exit(0); } - + // Mac Directory env = process.env["TMPDIR"]; if (env && (process.argv[1].indexOf(env) === 0 || process.argv[1].indexOf("/private"+env) === 0)) { process.exit(0); } - - } \ No newline at end of file diff --git a/scripts/uninstall.js b/scripts/uninstall.js index 7241379..e9d5fa3 100644 --- a/scripts/uninstall.js +++ b/scripts/uninstall.js @@ -38,23 +38,22 @@ deleteFolder(cwd+"css", appDir+"css"); // Update our main app.css to delete the import the theme if (fs.existsSync(appDir+"app.css")) { - var BOM=''; var cssData = fs.readFileSync(appDir + "app.css").toString(); - - - // Search for only our themes - var idx = cssData.indexOf("@import '~/css/core.light.css';"); - if (idx === -1) { - idx = cssData.indexOf("@import '~/css/core.dark.css';"); - } - + + + // Search for only our themes + var idx = cssData.indexOf("@import '~/css/core.light.css';"); + if (idx === -1) { + idx = cssData.indexOf("@import '~/css/core.dark.css';"); + } + if (idx !== -1) { - var idxOffset = cssData.indexOf(";", idx)+1; - if (idx === 0) { - cssData = cssData.substring(idxOffset, cssData.length); - } else { - cssData = cssData.substring(0, idx)+cssData.substring(idxOffset, cssData.length); - } + var idxOffset = cssData.indexOf(";", idx)+1; + if (idx === 0) { + cssData = cssData.substring(idxOffset, cssData.length); + } else { + cssData = cssData.substring(0, idx)+cssData.substring(idxOffset, cssData.length); + } fs.writeFileSync(appDir + "app.css", cssData.trim()); } } @@ -69,19 +68,19 @@ deleteFolder(cwd+"fonts", appDir+"fonts"); // ------------------------------------------------------ if (hasSCSS) { - var extraFiles=["_bootstrap-map.scss", "core.dark.android.scss", "core.dark.ios.scss", "core.light.android.scss", "core.light.ios.scss"]; - deleteFolder(cwd+"theme-core-scss", appDir+"theme-core-scss"); - - for (var i=0;i