[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[nodeJS] 046 File Append (sync)

"046-1 Writing files with #appendFileSync:data:options:"
| options |
options := ((#encoding -> #utf8),(#mode -> 0666),(#flag -> #a)).
[NodeJS fs appendFileSync: (TestPath, 'Sample46-1.txt') 
           data:'More S8 data.' 
           options: options ]
   on: Error
   do: [:ex| ^self error: '046-1 ' ,ex].


"046-2 Writing files with #appendFileSync:data:options: v2"
| options data jsObject|
options := ((#encoding -> #utf8),(#mode -> 0666),(#flag -> #a)).
jsObject := {'new Buffer(13)'}.
data := (NodeBuffer @ jsObject).
data write:'More S8 data.'. 
[NodeJS fs appendFileSync: (TestPath, 'Sample46-2.txt') 
           data: data 
           options: options ]
   on: Error
   do: [:ex| ^self error: '046-2 ' ,ex].


"046-3 Writing files with #appendFileSync:data:"
| options data jsObject|
options := ((#encoding -> #utf8),(#mode -> 0666),(#flag -> #a)).
jsObject := {'new Buffer(13)'}.
data := (NodeBuffer @ jsObject).
data write:'More S8 data.'. 
[NodeJS fs appendFileSync: (TestPath, 'Sample46-3.txt') 
           data: data ]
   on: Error
   do: [:ex| ^self error: '046-3 ' ,ex].


"046-4 Writing files with #appendFileSync:data: v2"
| options jsObject|
options := ((#encoding -> #utf8),(#mode -> 0666),(#flag -> #a)).
jsObject := {'new Buffer(13)'}.
[NodeJS fs appendFileSync: (TestPath, 'Sample46-4.txt') 
           data: 'More S8 data.']
   on: Error
   do: [:ex| self error: '046-4 ' ,ex].