Skip to content

Commit 4663eb7

Browse files
committed
Bump version, add custom extensions option
1 parent 069bc48 commit 4663eb7

File tree

3 files changed

+65
-36
lines changed

3 files changed

+65
-36
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log
22
All notable changes to the New Fractal Folder extension will be documented in this file.
33

4+
## 0.1.0
5+
SASS OPTION REMOVED 😿
6+
CUSTOM EXTENSIONS OPTION ADDED 🎉
7+
8+
*If you were previously generating a `.scss` or `.sass` file in the Sass Extension option, you will now need to add the extension to the Custom Extensions option.*
9+
10+
You can now add as many file extensions as you wish. Just enter a comma seperated list in the Custom Extensions option, such as `scss,jsx,partytime`, and each will be created as a file matching the folder name.
11+
412
## 0.0.4
513
- Add optional README file generation
614
- Remove numerical order prefix from file name

extension.js

+47-25
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function activate(context) {
3030
const settings = vscode.workspace.getConfiguration('new-fractal-folder');
3131
let targetPath;
3232

33-
console.log(settings);
33+
// console.log(settings);
3434

3535
if ( !isDir ) {
3636
targetPath = path.dirname(uriPath);
@@ -79,7 +79,7 @@ function activate(context) {
7979
fileName = fileName.replace(/^_/, '');
8080

8181
// Create fractal file
82-
fracalExt = settings.fractalFileFormat ? settings.fractalFileFormat : 'hbs';
82+
let fracalExt = settings.fractalFileFormat ? settings.fractalFileFormat : 'hbs';
8383
fs.writeFile(path.resolve(newPath, `${fileName}.${fracalExt}`), '', function (err) {
8484
if (err) throw err;
8585
});
@@ -102,42 +102,64 @@ function activate(context) {
102102
}
103103

104104
// Create config file with content
105-
fs.writeFile(path.resolve(newPath, `${fileName}.config.${configExt}`), configContent, function (err) {
105+
fs.writeFile(path.resolve(newPath, `${fileName}.config.${configExt}`), configContent, {encoding:"utf8"}, function (err) {
106106
if (err) throw err;
107107
});
108108

109-
// Sass file
110-
const sassOpts = settings.sassOptions;
111-
112-
let sassExt;
109+
// README.md file
110+
if ( settings.readmeFile ) {
111+
fs.writeFile(path.resolve(newPath, 'README.md'), '', function (err) {
112+
if (err) throw err;
113+
});
114+
}
113115

114-
switch (sassOpts) {
115-
case 'Create .sass file':
116-
sassExt = 'sass';
117-
break;
116+
// Custom Extensions
117+
let checkDeprecatedSassOpt = false;
118118

119-
case 'Do not generate sass file':
120-
sassExt = false;
121-
break;
119+
if ( settings.customExtensions.length && settings.customExtensions.length > 0 ) {
120+
let customExts = settings.customExtensions;
121+
customExts = customExts.split(',');
122122

123-
default:
124-
sassExt = 'scss';
123+
customExts.forEach((extName) => {
125124

126-
}
125+
if (extName == 'scss' || extName == 'sass') {
126+
checkDeprecatedSassOpt = false;
127+
}
127128

128-
if ( sassExt != false ) {
129-
fs.writeFile(path.resolve(newPath, `${fileName}.${sassExt}`), '', function (err) {
130-
if (err) throw err;
129+
fs.writeFile(path.resolve(newPath, `${fileName}.${extName}`), '', function (err) {
130+
if (err) throw err;
131+
});
131132
});
132133
}
133134

134-
// README.md file
135-
if ( settings.readmeFile ) {
136-
fs.writeFile(path.resolve(newPath, 'README.md'), '', function (err) {
137-
if (err) throw err;
138-
});
135+
// Backwards compatability: support deprecated sass option
136+
if ( settings.sassOptions && checkDeprecatedSassOpt ) {
137+
const sassOpts = settings.sassOptions;
138+
let sassExt;
139+
140+
switch (sassOpts) {
141+
case 'Create .sass file':
142+
sassExt = 'sass';
143+
break;
144+
145+
case 'Do not generate sass file':
146+
sassExt = false;
147+
break;
148+
149+
default:
150+
sassExt = 'scss';
151+
152+
}
153+
154+
if ( sassExt != false ) {
155+
fs.writeFile(path.resolve(newPath, `${fileName}.${sassExt}`), '', function (err) {
156+
if (err) throw err;
157+
});
158+
}
139159
}
140160

161+
162+
141163
});
142164
}
143165

package.json

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
"name": "new-fractal-folder",
33
"displayName": "New Fractal Folder",
44
"description": "Create a twig, scss, and config.js file with the same name of a new folder",
5-
"version": "0.0.4",
5+
"version": "0.1.0",
66
"publisher": "baerkins",
7+
"keywords": [
8+
"fractal",
9+
"create file"
10+
],
711
"repository": {
812
"type": "git",
913
"url": "https://github.com/baerkins/vscode-fractal-folder.git"
@@ -37,21 +41,16 @@
3741
],
3842
"default": "js",
3943
"description": "Type of config file to generate"
40-
},
41-
"new-fractal-folder.sassOptions": {
42-
"type": "string",
43-
"enum": [
44-
"Create .scss file",
45-
"Create .sass file",
46-
"Do not generate sass file"
47-
],
48-
"default": "Create .scss file",
49-
"description": "Sass options."
5044
},
5145
"new-fractal-folder.readmeFile": {
5246
"type": "boolean",
5347
"default": false,
5448
"description": "Create README.md file"
49+
},
50+
"new-fractal-folder.customExtensions": {
51+
"type": "string",
52+
"default": "",
53+
"description": "A comma seperated list of file extensions to create with folder name, without proceeding dot. Example: `scss,sass,less,styl`"
5554
}
5655
}
5756
},

0 commit comments

Comments
 (0)