New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coco/support for installing fonts #831
coco/support for installing fonts #831
Conversation
292b98c
to
db2142a
Compare
async function isNotEmptyDir(path) { | ||
const lstat = await fs.lstat(path); | ||
if (lstat.isDirectory()) { | ||
const dirs = await fs.readdir(path); | ||
if (!_.isEmpty(dirs)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !await isEmptyDir(path)
const absCodeUri = path.resolve(baseDir, codeUri); | ||
const fontsDir = path.join(absCodeUri, 'fonts'); | ||
|
||
if (!await fs.pathExists(fontsDir) || !await isNotEmptyDir(fontsDir)) { return {}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!await isNotEmptyDir(fontsDir) 不就等于 await isEmptyDir(fontsDir)?后者已经有这个方法了吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
添加了注释 仅当路径为目录且目录下有文件是返回 ture
@@ -37,6 +37,8 @@ program | |||
.description('install dependencies which are described in fun.yml file.') | |||
.action(async (packageNames, program) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不要写 .action 的方式了,commander 5.0 应该是有改动,可以把这个逻辑放到 if (!program.args.length) { 的 else 条件里
@@ -37,6 +37,8 @@ program | |||
.description('install dependencies which are described in fun.yml file.') | |||
.action(async (packageNames, program) => { | |||
|
|||
if (_.isEmpty(packageNames)) { return; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个就不需要了
src/lib/fc.js
Outdated
@@ -171,14 +172,19 @@ const CUSTOM_RUNTIME_JAVA_MAPPING = { | |||
'pathSuffix': '*' | |||
}; | |||
|
|||
const FONTS__MAPPING = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多了一个下划线吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/lib/fc.js
Outdated
@@ -983,6 +992,39 @@ function generateNasAndVpcConfig(mountTarget, securityGroupId, serviceName) { | |||
}; | |||
} | |||
|
|||
function writeFileToLine(filePath, content, lineNum) { | |||
let data = fs.readFileSync(filePath, 'utf8').split(/\r\n|\n|\r/gm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\r?\n
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fix #822