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

Support Node.js 10 #3

Merged
merged 1 commit into from
Jul 20, 2020
Merged

Support Node.js 10 #3

merged 1 commit into from
Jul 20, 2020

Conversation

lights0123
Copy link
Contributor

As mentioned in sindresorhus/electron-store#103, this package can support earlier Node.js versions. Version 8 failed in a Docker container, but 10 didn't, so that's what I went with.

Also included lodash as a dev dependency, as I presume that you had it installed globally on your machine.

@lights0123
Copy link
Contributor Author

If you're interested, here's the output of the failed test on Node.js 8:

user@89b7c7c59613:~/Documents/Projects/atomically$ npm run test   

> atomically@1.3.1 test /home/user/Documents/Projects/atomically
> tap --no-coverage-report

 PASS  test/concurrency.js 39 OK 551.502ms
 PASS  test/integration.js 68 OK 921.345ms
 FAIL  test/basic.js
 ✖ expect falsey value

  test/basic.js                                                                                                                             
  249 |     const pathMissingFolders = path.join(os.tmpdir(),String(Math.random()),String(Math.random()),String(Math.random()),'foo.txt');  
  250 |     writeFileAtomicNative(pathMissingFolders,'test', err => {                                                                       
> 251 |       t.notOk(err)                                                                                                                  
      | --------^                                                                                                                           
  252 |     })                                                                                                                              
  253 |   })                                                                                                                                
  254 |                                                                                                                                     

  test: test/basic.js async tests non-root tests
  stack: |
    err (test/basic.js:251:9)
    <anonymous>

 FAIL  test/basic.js
 ✖ expect falsey value

  test/basic.js                                                                                                                             
  245 |     const {writeFile: writeFileAtomicNative} = requireInject('../dist', { fs });                                                    
  246 |     writeFileAtomicNative(longPath,'test', err => {                                                                                 
> 247 |       t.notOk(err)                                                                                                                  
      | --------^                                                                                                                           
  248 |     })                                                                                                                              
  249 |     const pathMissingFolders = path.join(os.tmpdir(),String(Math.random()),String(Math.random()),String(Math.random()),'foo.txt');  
  250 |     writeFileAtomicNative(pathMissingFolders,'test', err => {                                                                       

  test: test/basic.js async tests non-root tests
  stack: |
    err (test/basic.js:247:9)
    <anonymous>

 FAIL  test/basic.js
 ✖ temp files are purged on success

  test/basic.js                                   
  299 |     let err                               
  300 |     try { todo() } catch (e) { err = e }  
> 301 |     t.ifError(err, msg)                   
      | ------^                                   
  302 |   }                                       
  303 |   let tmpfile                             
  304 |                                           

  test: test/basic.js sync tests non-root
  origin:
    at:
      line: 766
      column: 18
      file: fs.js
      function: apply
    stack: |
      apply (dist/utils/retryify.js:26:27)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      attempt (dist/utils/retryify.js:32:36)
    errno: -1
    code: EPERM
    syscall: rename
    path: /tmp/atomically-test-0.temp
    dest: /tmp/atomically-test-0
  found:
    !error
    name: Error
    message: "EPERM: operation not permitted, rename '/tmp/atomically-test-0.temp'
      -> '/tmp/atomically-test-0'"
    stack: >-
      Error:
          at apply (fs.js:766:18)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:26:27)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at attempt (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
    errno: -1
    code: EPERM
    syscall: rename
    path: /tmp/atomically-test-0.temp
    dest: /tmp/atomically-test-0
  stack: |
    noexception (test/basic.js:301:7)
    Test.t.test.t (test/basic.js:397:5)
    Test.t (test/basic.js:305:5)
    err (test/basic.js:279:7)
    <anonymous>

 FAIL  test/basic.js
 ✖ temp files can also not be purged on error

  test/basic.js                                          
  294 |     let err                                      
  295 |     try { todo() } catch (e) { err = e }         
> 296 |     t.is(shouldthrow, err && err.message, msg)   
      | ------^                                          
  297 |   }                                              
  298 |   const noexception = function (t, msg, todo) {  
  299 |     let err                                      

  --- expected                                                            
  +++ actual                                                              
  @@ -1,1 +1,1 @@                                                         
  -EACCES: permission denied, open '/tmp/atomically-test-norename-2.temp' 
  +ENORENAME                                                              

  test: test/basic.js sync tests non-root
  stack: |
    throws (test/basic.js:296:7)
    Test.t.test.t (test/basic.js:413:5)
    Test.t (test/basic.js:305:5)
    err (test/basic.js:279:7)
    <anonymous>

 FAIL  test/basic.js
 ✖ temp files are truncated

  test/basic.js                                   
  299 |     let err                               
  300 |     try { todo() } catch (e) { err = e }  
> 301 |     t.ifError(err, msg)                   
      | ------^                                   
  302 |   }                                       
  303 |   let tmpfile                             
  304 |                                           

  test: test/basic.js sync tests non-root
  origin:
    at:
      line: 761
      column: 25
      file: fs.js
      function: apply
    stack: |
      apply (dist/utils/retryify.js:26:27)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      apply (dist/utils/retryify.js:32:36)
      attempt (dist/utils/retryify.js:32:36)
    type: RangeError
  found:
    !error
    name: RangeError
    message: Maximum call stack size exceeded
    stack: >-
      RangeError:
          at apply (fs.js:761:25)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:26:27)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at apply (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
          at attempt (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:32:36)
  stack: |
    noexception (test/basic.js:301:7)
    Test.t.test.t (test/basic.js:420:5)
    Test.t (test/basic.js:305:5)
    err (test/basic.js:279:7)
    <anonymous>

 FAIL  test/basic.js
 ✖ parent folders are created

  test/basic.js                                   
  299 |     let err                               
  300 |     try { todo() } catch (e) { err = e }  
> 301 |     t.ifError(err, msg)                   
      | ------^                                   
  302 |   }                                       
  303 |   let tmpfile                             
  304 |                                           

  test: test/basic.js sync tests non-root
  origin:
    at:
      line: 646
      column: 18
      file: fs.js
      function: apply
    stack: |
      attempt (dist/utils/retryify.js:26:27)
      writeFileSync (dist/index.js:136:14)
      noexception (test/basic.js:427:7)
      noexception (test/basic.js:300:11)
      Test.t.test.t (test/basic.js:425:5)
    errno: -2
    code: ENOENT
    syscall: open
    path: /tmp/0.28287465377020693/0.6245907721345334/0.7125146804257945/foo.txt.tmp-5214357407d910f6
  found:
    !error
    name: Error
    message: "ENOENT: no such file or directory, open
      '/tmp/0.28287465377020693/0.6245907721345334/0.7125146804257945/foo.txt.tmp\
      -5214357407d910f6'"
    stack: >-
      Error:
          at apply (fs.js:646:18)
          at attempt (/home/user/Documents/Projects/atomically/dist/utils/retryify.js:26:27)
          at writeFileSync (/home/user/Documents/Projects/atomically/dist/index.js:136:14)
          at noexception (/home/user/Documents/Projects/atomically/test/basic.js:427:7)
          at noexception (/home/user/Documents/Projects/atomically/test/basic.js:300:11)
          at Test.t.test.t (/home/user/Documents/Projects/atomically/test/basic.js:425:5)
          at TapWrap.runInAsyncScope (async_hooks.js:194:21)
          at Test.cb.args (/home/user/Documents/Projects/atomically/node_modules/tap/lib/test.js:145:40)
          at ret (/home/user/Documents/Projects/atomically/node_modules/tap/lib/test.js:383:21)
          at Test.main (/home/user/Documents/Projects/atomically/node_modules/tap/lib/test.js:390:7)
    errno: -2
    code: ENOENT
    syscall: open
    path: /tmp/0.28287465377020693/0.6245907721345334/0.7125146804257945/foo.txt.tmp-5214357407d910f6
  stack: |
    noexception (test/basic.js:301:7)
    Test.t.test.t (test/basic.js:425:5)
    Test.t (test/basic.js:305:5)
    err (test/basic.js:279:7)
    <anonymous>

 FAIL  test/basic.js 6 failed of 82 6s
 ✖ expect falsey value
 ✖ expect falsey value
 ✖ temp files are purged on success
 ✖ temp files can also not be purged on error
 ✖ temp files are truncated
 ✖ parent folders are created


                         
  🌈 SUMMARY RESULTS 🌈  
                         

 FAIL  test/basic.js 6 failed of 82 6s
 ✖ expect falsey value
 ✖ expect falsey value
 ✖ temp files are purged on success
 ✖ temp files can also not be purged on error
 ✖ temp files are truncated
 ✖ parent folders are created

Suites:   1 failed, 2 passed, 3 of 3 completed
Asserts:  6 failed, 183 passed, of 189

@fabiospampinato fabiospampinato merged commit 31738e6 into fabiospampinato:master Jul 20, 2020
@fabiospampinato
Copy link
Owner

v10 and v10.10 didn't pass the test suite in my system, but v10.12 did, I went with that. Available in v1.3.2 👍

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.

None yet

2 participants