Skip to content
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

Dev: Add new tests for get-functions.js #548

Merged
merged 1 commit into from
Sep 19, 2019

Conversation

polemius
Copy link
Contributor

- Summary

I've added the test for get-functions.js

- Test plan

Please, run the test get-functions.test.js

- Description for the changelog

New test for get-functions.js

Copy link
Contributor

@RaeesBhatti RaeesBhatti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thank you for the PR @polemius 🌸

@RaeesBhatti RaeesBhatti merged commit 564046d into netlify:master Sep 19, 2019
@polemius
Copy link
Contributor Author

I'm happy to help :)

@polemius polemius deleted the add_test_get_functions branch September 20, 2019 04:34
@polemius
Copy link
Contributor Author

Also I have a question:

if (dir === 'node_modules') {

Here should be the variable dir?
If yes, then I believe we can lift this if up, like this:

 getFunctions(dir) {
    const functions = {}
+   if (dir === 'node_modules') {
+      return
+   }
    if (fs.existsSync(dir)) {
      fs.readdirSync(dir).forEach(file => {
-       if (dir === 'node_modules') {
-         return
-       }
        const functionPath = path.resolve(path.join(dir, file))

if not, then if should check file variable:

 getFunctions(dir) {
    const functions = {}
    if (fs.existsSync(dir)) {
      fs.readdirSync(dir).forEach(file => {
-       if (dir === 'node_modules') {
+       if (file === 'node_modules') {
          return
        }
        const functionPath = path.resolve(path.join(dir, file))

@polemius Am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants