ether-code 0.6.8 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli/ether.js +20 -22
  2. package/package.json +1 -1
package/cli/ether.js CHANGED
@@ -6,7 +6,7 @@ const http = require('http')
6
6
  const { EtherCompiler } = require('./compiler')
7
7
  const { Watcher } = require('./watcher')
8
8
 
9
- const VERSION = '0.6.8'
9
+ const VERSION = '0.6.9'
10
10
 
11
11
  const COLORS = {
12
12
  reset: '\x1b[0m',
@@ -21,15 +21,15 @@ const COLORS = {
21
21
  }
22
22
 
23
23
  const MIME_TYPES = {
24
- '.html': 'text/html',
25
- '.css': 'text/css',
26
- '.js': 'application/javascript',
27
- '.json': 'application/json',
24
+ '.html': 'text/html; charset=utf-8',
25
+ '.css': 'text/css; charset=utf-8',
26
+ '.js': 'application/javascript; charset=utf-8',
27
+ '.json': 'application/json; charset=utf-8',
28
28
  '.png': 'image/png',
29
29
  '.jpg': 'image/jpeg',
30
30
  '.jpeg': 'image/jpeg',
31
31
  '.gif': 'image/gif',
32
- '.svg': 'image/svg+xml',
32
+ '.svg': 'image/svg+xml; charset=utf-8',
33
33
  '.ico': 'image/x-icon',
34
34
  '.woff': 'font/woff',
35
35
  '.woff2': 'font/woff2',
@@ -496,7 +496,7 @@ function startServer(outDir, publicDir, port) {
496
496
  const ext = path.extname(filePath).toLowerCase()
497
497
  const mime = MIME_TYPES[ext] || 'application/octet-stream'
498
498
 
499
- fs.readFile(filePath, function(err, content) {
499
+ fs.readFile(filePath, 'utf-8', function(err, content) {
500
500
  if (err) {
501
501
  res.writeHead(500)
502
502
  res.end('Erreur: ' + err.message)
@@ -504,17 +504,15 @@ function startServer(outDir, publicDir, port) {
504
504
  }
505
505
 
506
506
  if (ext === '.html') {
507
- let html = content.toString()
508
- if (html.indexOf('</body>') !== -1) {
509
- html = html.replace('</body>', liveReloadScript + '</body>')
507
+ if (content.indexOf('</body>') !== -1) {
508
+ content = content.replace('</body>', liveReloadScript + '</body>')
510
509
  } else {
511
- html = html + liveReloadScript
510
+ content = content + liveReloadScript
512
511
  }
513
- content = html
514
512
  }
515
513
 
516
514
  res.writeHead(200, { 'Content-Type': mime })
517
- res.end(content)
515
+ res.end(content, 'utf-8')
518
516
  })
519
517
  })
520
518
 
@@ -557,8 +555,8 @@ function cmdInit() {
557
555
  if (!fs.existsSync(imagesDir)) fs.mkdirSync(imagesDir, { recursive: true })
558
556
  if (!fs.existsSync(videosDir)) fs.mkdirSync(videosDir, { recursive: true })
559
557
 
560
- fs.writeFileSync(path.join(imagesDir, 'logo.svg'), LOGO_SVG)
561
- fs.writeFileSync(path.join(publicDir, 'favicon.svg'), FAVICON_SVG)
558
+ fs.writeFileSync(path.join(imagesDir, 'logo.svg'), LOGO_SVG, 'utf-8')
559
+ fs.writeFileSync(path.join(publicDir, 'favicon.svg'), FAVICON_SVG, 'utf-8')
562
560
 
563
561
  const configContent = 'module.exports = {\n src: "src",\n out: "dist",\n public: "public",\n port: 3000,\n lang: "fr"\n}\n'
564
562
 
@@ -675,11 +673,11 @@ console.log("Ether v0.3.8 ready!")
675
673
 
676
674
  const packageContent = '{\n "name": "mon-projet-ether",\n "version": "1.0.0",\n "scripts": {\n "dev": "ether dev",\n "build": "ether build"\n }\n}\n'
677
675
 
678
- fs.writeFileSync(path.join(projectDir, 'ether.config.js'), configContent)
679
- fs.writeFileSync(path.join(srcDir, 'index.eth'), indexContent)
680
- fs.writeFileSync(path.join(srcDir, 'styles.eth'), STYLES_ETH)
681
- fs.writeFileSync(path.join(srcDir, 'app.eth'), appContent)
682
- fs.writeFileSync(path.join(projectDir, 'package.json'), packageContent)
676
+ fs.writeFileSync(path.join(projectDir, 'ether.config.js'), configContent, 'utf-8')
677
+ fs.writeFileSync(path.join(srcDir, 'index.eth'), indexContent, 'utf-8')
678
+ fs.writeFileSync(path.join(srcDir, 'styles.eth'), STYLES_ETH, 'utf-8')
679
+ fs.writeFileSync(path.join(srcDir, 'app.eth'), appContent, 'utf-8')
680
+ fs.writeFileSync(path.join(projectDir, 'package.json'), packageContent, 'utf-8')
683
681
 
684
682
  logSuccess('Projet initialise!')
685
683
  console.log('')
@@ -745,7 +743,7 @@ function cmdBuild(options) {
745
743
  fs.mkdirSync(outDirPath, { recursive: true })
746
744
  }
747
745
 
748
- fs.writeFileSync(outPath, output.content)
746
+ fs.writeFileSync(outPath, output.content, 'utf-8')
749
747
 
750
748
  if (options.verbose) {
751
749
  logSuccess(relativePath + ' -> ' + output.path)
@@ -825,7 +823,7 @@ function cmdDev(options) {
825
823
  fs.mkdirSync(outDirPath, { recursive: true })
826
824
  }
827
825
 
828
- fs.writeFileSync(outPath, output.content)
826
+ fs.writeFileSync(outPath, output.content, 'utf-8')
829
827
  logSuccess('-> ' + output.path)
830
828
  }
831
829
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ether-code",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Ether - Le langage intentionnel",
5
5
  "main": "cli/compiler.js",
6
6
  "bin": {