Skip to content

Commit 5e4939d

Browse files
committed
fix: #10 bug: Throws an error if scss-file is empty
* Will no longer throw an error for empty files * nativescript-angular: ng2 throws errors if css-files doesn't exist, to accommodate that write empty css-files if the sass-file is empty
1 parent 0619ec6 commit 5e4939d

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

lib/converter.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ function convert(logger, projectDir, options) {
5454
function parseSass(filePath, importPaths, callback){
5555
var sassFileContent = fs.readFileSync(filePath, { encoding: 'utf8'});
5656
var cssFilePath = filePath.replace('.scss', '.css');
57-
57+
58+
if(sassFileContent.trim().length === 0) {
59+
// No SASS content write an empty file
60+
fs.writeFile(cssFilePath, '', 'utf8', function(){
61+
callback();
62+
});
63+
return;
64+
}
65+
5866
sass.render({
5967
data: sassFileContent,
6068
includePaths: importPaths,
@@ -66,14 +74,15 @@ function parseSass(filePath, importPaths, callback){
6674
callback(e);
6775
}
6876

69-
if(output === null){
70-
//No CSS content in converted scss file; No need to write file
71-
callback();
77+
if(output && output.css){
78+
output = output.css;
7279
} else {
73-
fs.writeFile(cssFilePath, output.css, 'utf8', function(){
74-
//File done writing
75-
callback();
76-
});
77-
}
80+
output = '';
81+
}
82+
83+
fs.writeFile(cssFilePath, output, 'utf8', function(){
84+
//File done writing
85+
callback();
86+
});
7887
});
79-
}
88+
}

0 commit comments

Comments
 (0)