Browse Source

Merge branch 'issue51' into nodejs-examples-to-v13

hhzl 9 years ago
parent
commit
d1a924bd2d
2 changed files with 23 additions and 0 deletions
  1. 6 0
      nodejs/Gruntfile.js
  2. 17 0
      nodejs/writefile/WriteFile.st

+ 6 - 0
nodejs/Gruntfile.js

@@ -17,6 +17,12 @@ module.exports = function(grunt) {
         amd_namespace: 'amber_examples_hello',
         output_name: 'hello/Program'
       },
+      writefile: {
+        src: ['writefile/WriteFile.st'],
+        main_class: 'WriteFile',
+        amd_namespace: 'amber_examples_hello',
+        output_name: 'writefile/Program'
+      },
       benchfib: {
         src: ['benchfib/Benchfib.st'],
         main_class: 'Benchfib',

+ 17 - 0
nodejs/writefile/WriteFile.st

@@ -0,0 +1,17 @@
+Object subclass: #WriteFile
+    instanceVariableNames: ''
+    package: 'WriteFileExample'!
+
+!WriteFile class methodsFor: 'main'!
+
+
+main
+| fs |
+    console log: 'Writing a file called "message.txt".'.
+
+    fs := require value: 'fs'.
+
+    fs writeFileSync: 'message.txt' content: 'This file was written by Amber.' 
+       errFn:  nil.
+
+! !