Skip to content

Commit

Permalink
Merge pull request #103 from rolldone/working
Browse files Browse the repository at this point in the history
Working
  • Loading branch information
rolldone authored Mar 24, 2022
2 parents 0e11b26 + 7f0b9a4 commit a496217
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "npx webpack --watch",
"build": "npx webpack --config webpack.config.prod.js"
"build": "npx webpack --config webpack.config.prod.js",
"compile": "pkg ."
},
"pkg": {
"scripts": [
"dist/**/*.js",
"node_modules/node-pty/**/*.js"
],
"assets": [
"dist/example.yaml",
"dist/ngi-sync-agent-linux.tar.gz"
],
"targets": [
"node14-win-x64",
"node14-linux"
],
"outputPath": "dist_prod"
},
"author": "",
"license": "ISC",
Expand Down
16 changes: 9 additions & 7 deletions src/app/load_save/services/LoadSaveDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,15 @@ export default BaseService.extend<LoadSaveServiceInterface>({
let _fileName = _config._filename;
let bodyData: any = readFileSync(_fileName);
bodyData = YAML.parse(bodyData.toString()) as any;
bodyData.saved_file_name = whatFileName + '.yaml';
writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + bodyData.saved_file_name, YAML.stringify(bodyData, null), 'utf8');
bodyData.saved_file_name = whatFileName+'.yaml';
whatFileName = upath.basename(whatFileName,".yaml");
writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName+'.yaml', YAML.stringify(bodyData, null), 'utf8');
/* Add sync_ignore can self by owner ngi-sync */
if (existsSync(".sync_ignore")) {
let syncIgnoreData = readFileSync(".sync_ignore").toString();
writeFileSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + ".sync_ignore", syncIgnoreData, 'utf8');
}
console.log(`${this._baseAppPathFolder + '/.sync_collections/' + bodyData.saved_file_name} is created!`);
console.log(`${this._baseAppPathFolder + '/.sync_collections/' + whatFileName+'.yaml'} is created!`);
} catch (ex) {
console.error('createNewSave - ex ', ex);
}
Expand All @@ -262,12 +263,13 @@ export default BaseService.extend<LoadSaveServiceInterface>({
deleteDataSave: function () {
try {
let { target_delete } = this._completeData;
unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + target_delete + '.yaml');
let whatFileName = upath.basename(target_delete,".yaml");
unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + '.yaml');
/* Delete sync_ignore can self by owner ngi-sync */
if (existsSync(this._baseAppPathFolder + "/.sync_collections/" + target_delete + ".sync_ignore")) {
unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + target_delete + ".sync_ignore");
if (existsSync(this._baseAppPathFolder + "/.sync_collections/" + whatFileName + ".sync_ignore")) {
unlinkSync(this._baseAppPathFolder + '/.sync_collections/' + whatFileName + ".sync_ignore");
}
console.log(`${this._baseAppPathFolder + '/.sync_collections/' + target_delete + '.yaml'} is deleted!`);
console.log(`${this._baseAppPathFolder + '/.sync_collections/' + whatFileName + '.yaml'} is deleted!`);
} catch (ex) {
console.error('deleteDataSave - ex ', ex);
}
Expand Down

0 comments on commit a496217

Please sign in to comment.