-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from Serverless-Devs/develop
pre 0.1.44
- Loading branch information
Showing
11 changed files
with
720 additions
and
494 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
DEFAULT_CORE_VERSION: '0.1.43', | ||
DEFAULT_CORE_VERSION: '0.1.44', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './utils'; | ||
export * from './common'; | ||
export { default as getYamlContent } from './getYamlContent'; | ||
export { default as isYamlFile } from './isYamlFile'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import yaml from 'js-yaml'; | ||
import chalk from 'chalk'; | ||
|
||
async function isYamlFile(filePath: string) { | ||
if (!fs.existsSync(filePath)) { | ||
throw new Error(`${filePath} file was not found.`); | ||
} | ||
const arr = ['.yaml', '.yml']; | ||
if (!arr.includes(path.extname(filePath))) { | ||
throw new Error(`${filePath} file should be yaml or yml file.`); | ||
} | ||
try { | ||
await yaml.load(fs.readFileSync(filePath, 'utf8')); | ||
} catch (error /* YAMLException */) { | ||
const filename = path.basename(filePath); | ||
let message = `${filename} format is incorrect`; | ||
if (error.message) message += `: ${error.message}`; | ||
throw new Error( | ||
JSON.stringify({ | ||
message, | ||
tips: `Please check the configuration of ${filename}, Serverless Devs' Yaml specification document can refer to:${chalk.underline( | ||
'https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/zh/yaml.md', | ||
)}`, | ||
}), | ||
); | ||
} | ||
} | ||
|
||
export default isYamlFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters