@symbo.ls/socket 0.0.5 → 0.0.6

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/package.json +1 -1
  2. package/server.js +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/socket",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Connect your app to Symbols editor",
5
5
  "main": "server.js",
6
6
  "author": "symbo.ls",
package/server.js CHANGED
@@ -5,15 +5,16 @@ import express from 'express'
5
5
  import http from 'http'
6
6
  import { Server } from 'socket.io'
7
7
  import { dirname } from 'path' // eslint-disable-line
8
- import merge from 'merge-deep'
8
+ import merge from 'merge-deep' // use the require method
9
+
10
+ import { createRequire } from 'module'
9
11
 
10
- import { createRequire } from 'module' // Bring in the ability to create the 'require' method
11
12
  const require = createRequire(import.meta.url) // construct the require method
12
- const SYMBOLS_RC = require('@symbo.ls/init/src/dynamic.json') // use the require method
13
+ const DYNAMIC_CONFIG = require('@symbo.ls/init/src/dynamic.json') // Bring in the ability to create the 'require' method
13
14
 
14
15
  const app = express()
15
16
 
16
- export const sync = (symbolsInitFile = SYMBOLS_RC) => {
17
+ export const sync = (symbolsInitFile = DYNAMIC_CONFIG) => {
17
18
  const server = http.createServer(app)
18
19
 
19
20
  const io = new Server(server, {
@@ -30,10 +31,10 @@ export const sync = (symbolsInitFile = SYMBOLS_RC) => {
30
31
  io.on('connection', (socket) => {
31
32
  console.log('a user connected')
32
33
 
33
- socket.emit('init', SYMBOLS_RC)
34
+ socket.emit('init', symbolsInitFile)
34
35
 
35
36
  socket.on('change', change => {
36
- const newMerge = merge(SYMBOLS_RC, change)
37
+ const newMerge = merge(change, symbolsInitFile)
37
38
  const mergeStr = JSON.stringify(newMerge, null, 2)
38
39
  const initPath = process.cwd() + '/node_modules/@symbo.ls/init/src/dynamic.json'
39
40
  fs.writeFile(initPath, mergeStr, function (err) {