[update] Prevent new version if no change
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ class App
|
|||||||
_options.domain = ip.address()
|
_options.domain = ip.address()
|
||||||
|
|
||||||
if( typeof _options.port === 'undefined' )
|
if( typeof _options.port === 'undefined' )
|
||||||
_options.port = 3000
|
_options.port = 1571
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
this.options = _options
|
this.options = _options
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ The project URL appears. Share it with the viewers on the same wifi.
|
|||||||
|
|
||||||
### Todo
|
### Todo
|
||||||
|
|
||||||
- [ ] Prevent new version if no change
|
|
||||||
- [ ] Ignore too big files
|
- [ ] Ignore too big files
|
||||||
- [ ] Ignore non txt files
|
- [ ] Ignore non txt files
|
||||||
- [ ] NPM package
|
- [ ] NPM package
|
||||||
|
|||||||
+6
-6
@@ -229,7 +229,7 @@ class App
|
|||||||
{
|
{
|
||||||
project = this.projects.create_project( data.name )
|
project = this.projects.create_project( data.name )
|
||||||
|
|
||||||
console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
// console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Update file
|
// Update file
|
||||||
@@ -237,7 +237,7 @@ class App
|
|||||||
{
|
{
|
||||||
project.files.create_version( data.path, data.content )
|
project.files.create_version( data.path, data.content )
|
||||||
|
|
||||||
console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
// console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Create file
|
// Create file
|
||||||
@@ -245,7 +245,7 @@ class App
|
|||||||
{
|
{
|
||||||
project.files.create( data.path, data.content )
|
project.files.create( data.path, data.content )
|
||||||
|
|
||||||
console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
// console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Delete file
|
// Delete file
|
||||||
@@ -253,15 +253,15 @@ class App
|
|||||||
{
|
{
|
||||||
project.files.delete( data.path )
|
project.files.delete( data.path )
|
||||||
|
|
||||||
console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
// console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Disconnect
|
// Disconnect
|
||||||
socket.on( 'disconnect', () =>
|
socket.on( 'disconnect', () =>
|
||||||
{
|
{
|
||||||
console.log( 'socket app'.green.bold + ' - ' + 'disconnect'.cyan + ' - ' + socket.id.cyan )
|
|
||||||
|
|
||||||
this.projects.delete_project( project.slug )
|
this.projects.delete_project( project.slug )
|
||||||
|
|
||||||
|
console.log( 'socket app'.green.bold + ' - ' + 'disconnect'.cyan + ' - ' + socket.id.cyan )
|
||||||
} );
|
} );
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// Depedencies
|
// Depedencies
|
||||||
let diff = require( 'diff' ),
|
let diff = require( 'diff' ),
|
||||||
|
util = require( 'util' ),
|
||||||
paths = require( '../utils/paths.class.js' ),
|
paths = require( '../utils/paths.class.js' ),
|
||||||
ids = require( '../utils/ids.class.js' )
|
ids = require( '../utils/ids.class.js' )
|
||||||
|
|
||||||
@@ -39,8 +40,11 @@ class File
|
|||||||
version.content = content
|
version.content = content
|
||||||
|
|
||||||
if( !last_version )
|
if( !last_version )
|
||||||
|
{
|
||||||
version.diff = false
|
version.diff = false
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
version.diff = diff.diffLines(
|
version.diff = diff.diffLines(
|
||||||
last_version.content,
|
last_version.content,
|
||||||
version.content,
|
version.content,
|
||||||
@@ -49,6 +53,11 @@ class File
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// No changed
|
||||||
|
if( version.diff.length === 1 )
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Emit
|
// Emit
|
||||||
this.socket.emit( 'create_version', { file: this.path.full, version: version } )
|
this.socket.emit( 'create_version', { file: this.path.full, version: version } )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user