Skip to content

Commit b0a4bd5

Browse files
committed
修复增加创建任务时修改作者匹配不正确的问题
1 parent bf80be1 commit b0a4bd5

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

workflow/lib.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var lib = {};
44

55
lib.checkDateFormat = function(_date) {
66
if (_date < 10) {
7-
_date = '0' + _date;
7+
_date = '0' + _date;
88
}
9-
return _date;
9+
return _date;
1010
};
1111

1212
lib.getCurrentTime = function(){
@@ -34,4 +34,9 @@ lib.deleteElementInArray = function(_array, _element) {
3434
}
3535
}
3636

37+
// 使字符串的第一个字符大写
38+
lib.upperFirst = function(_data) {
39+
return _data.substring(0, 1).toUpperCase() + _data.substring(1);
40+
}
41+
3742
module.exports = lib;

workflow/task/initProject.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,21 @@ module.exports = function(gulp, common) {
3535
_currentMonth = common.lib.checkDateFormat(_currentDate.getMonth() + 1),
3636
_currentDay = common.lib.checkDateFormat(_currentDate.getDate()),
3737
_formattingDate = _currentYear + '-' + _currentMonth + '-' + _currentDay,
38-
_targetQmuiStylePath = '../' + path.resolve('.').replace(/\\/g, '/').split('/').pop() + '/qmui/_qmui.scss';
38+
_targetQmuiStylePath = '../' + path.resolve('.').replace(/\\/g, '/').split('/').pop() + '/qmui/_qmui.scss',
39+
_authorName = common.lib.upperFirst(path.basename(os.homedir()));
3940

4041
// 执行创建项目的任务
4142
gulp.src(_sourceArr)
4243
.pipe(common.plugins.replace('qui_', common.config.prefix + '_'))
4344
.pipe(common.plugins.replace(_dateRegex, _formattingDate))
44-
.pipe(common.plugins.replace(/@author .*\n$/, '@author ' + path.basename(os.homedir()) + '\n'))
45+
.pipe(common.plugins.replace(/@author .*\n/, '@author ' + _authorName + '\n'))
4546
.pipe(gulp.dest('../project'));
4647

4748
gulp.src(['project/demo.scss'])
4849
.pipe(common.plugins.replace('../qmui/_qmui.scss', _targetQmuiStylePath))
4950
.pipe(common.plugins.replace('demo.scss', common.config.resultCssFileName))
5051
.pipe(common.plugins.replace(_dateRegex, _formattingDate))
51-
.pipe(common.plugins.replace(/@author .*\n$/, '@author ' + path.basename(os.homedir()) + '\n'))
52+
.pipe(common.plugins.replace(/@author .*\n/, '@author ' + _authorName + '\n'))
5253
.pipe(common.plugins.rename(common.config.resultCssFileName))
5354
.pipe(gulp.dest('../project'));
5455

0 commit comments

Comments
 (0)