Skip to content

Commit

Permalink
fix: correct version in compiled css for published versions
Browse files Browse the repository at this point in the history
closes #91
  • Loading branch information
NathanWalker committed Oct 29, 2016
1 parent a93d343 commit d8ab630
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nativescript-theme-core.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-theme-core",
"version": "0.1.3",
"version": "0.1.4",
"description": "Telerik NativeScript Core Theme",
"author": "Telerik <[email protected]>",
"homepage": "https://www.nativescript.org",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-theme-core",
"version": "0.1.3",
"version": "0.1.4",
"description": "Telerik NativeScript Core Theme",
"homepage": "https://www.nativescript.org",
"license": "Apache-2.0",
Expand Down
17 changes: 15 additions & 2 deletions scripts/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ function copySCSS() {
*/
function createCSSFromSCSS() {

var packageFile = './package.json';
var packageJSON = {};

if (fs.existsSync(packageFile)) {
packageJSON = require(packageFile);
}
var version = packageJSON ? packageJSON.version : null;

var sassFilesPath = './app/**/*.scss';
var sassImportPaths = [
'./app/',
Expand All @@ -134,7 +142,7 @@ function createCSSFromSCSS() {
if (sassFiles[i].indexOf('/core.') === -1) {
continue;
}
parseSass(sassFiles[i], sassImportPaths);
parseSass(sassFiles[i], sassImportPaths, version);
}
}

Expand All @@ -143,7 +151,7 @@ function createCSSFromSCSS() {
* @param sassFile - File to load
* @param importPaths - Other import paths
*/
function parseSass(sassFile, importPaths) {
function parseSass(sassFile, importPaths, version) {
var sassFileContent = fs.readFileSync(sassFile, { encoding: 'utf8'});
var outputFile = 'nativescript-theme-core/css';
var offset = sassFile.lastIndexOf('/');
Expand All @@ -156,6 +164,11 @@ function parseSass(sassFile, importPaths) {
outFile: cssFilePath,
outputStyle: 'compressed'
});
if (version) {
// correct version tag
var name = 'NativeScript Theme v';
output.replace(name, name + version);
}
fs.writeFileSync(cssFilePath, output.css, 'utf8');
}

Expand Down

0 comments on commit d8ab630

Please sign in to comment.