Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
epoc-editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
learninglab
epoc
epoc-editor
Commits
6768c7c7
Commit
6768c7c7
authored
1 year ago
by
VIAUD Nathan
Browse files
Options
Downloads
Patches
Plain Diff
Fix prune for windows
parent
b3b639a6
No related branches found
No related tags found
1 merge request
!83
Resolve "Prune assets doesn't on windows because of path separators"
Pipeline
#880700
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
electron/components/file.js
+29
-21
29 additions, 21 deletions
electron/components/file.js
with
29 additions
and
21 deletions
electron/components/file.js
+
29
−
21
View file @
6768c7c7
...
@@ -164,21 +164,36 @@ const saveAsEpocProject = async function (project) {
...
@@ -164,21 +164,36 @@ const saveAsEpocProject = async function (project) {
};
};
/**
/**
* Zip the content of an ePoc project file from the project workdir
* Zip files of an ePoc project
* @returns {string}
* @param {string} workdir the path to the workdir
* @param {string} filepath the path to the .epoc project file
* @param {boolean} exporting if true, the project.json file will not be included
*/
*/
const
zipEpocProject
=
async
function
(
workdir
,
filepath
)
{
const
zipFiles
=
async
function
(
workdir
,
filepath
,
exporting
)
{
if
(
!
filepath
||
!
workdir
)
return
null
;
// Do not use path.join here, admZIP normalize the entries path
const
unusedAssets
=
getUnusedAssets
(
workdir
).
map
(
asset
=>
'
assets/
'
+
asset
);
const
unusedAssets
=
getUnusedAssets
(
workdir
).
map
(
asset
=>
path
.
join
(
'
assets
'
,
asset
));
const
excluded
=
[
'
.DS_Store
'
,
'
__MACOSX
'
,
'
.git
'
];
excluded
.
push
(...
unusedAssets
);
if
(
exporting
)
excluded
.
push
(
'
project.json
'
);
const
zip
=
new
AdmZip
();
const
zip
=
new
AdmZip
();
zip
.
addLocalFolder
(
workdir
,
''
,
(
entry
)
=>
{
zip
.
addLocalFolder
(
workdir
,
''
,
(
entry
)
=>
{
const
excluded
=
[
'
.DS_Store
'
,
'
__MACOSX
'
,
'
.git
'
];
excluded
.
push
(...
unusedAssets
);
return
excluded
.
every
(
e
=>
entry
.
indexOf
(
e
)
===
-
1
)
;
return
excluded
.
every
(
e
=>
entry
.
indexOf
(
e
)
===
-
1
)
;
});
});
await
zip
.
writeZipPromise
(
filepath
,
null
);
await
zip
.
writeZipPromise
(
filepath
,
null
);
};
/**
* Zip the content of an ePoc project file from the project workdir
* @returns {string}
*/
const
zipEpocProject
=
async
function
(
workdir
,
filepath
)
{
if
(
!
filepath
||
!
workdir
)
return
null
;
await
zipFiles
(
workdir
,
filepath
,
false
);
return
filepath
;
return
filepath
;
};
};
...
@@ -198,16 +213,9 @@ const exportProject = async function (workdir, filepath) {
...
@@ -198,16 +213,9 @@ const exportProject = async function (workdir, filepath) {
if
(
!
exportPath
)
return
null
;
if
(
!
exportPath
)
return
null
;
const
unusedAssets
=
getUnusedAssets
(
workdir
).
map
(
asset
=>
path
.
join
(
'
assets
'
,
asset
));
await
zipFiles
(
workdir
,
exportPath
,
true
);
const
zip
=
new
AdmZip
();
zip
.
addLocalFolder
(
workdir
,
''
,
(
entry
)
=>
{
const
excluded
=
[
'
project.json
'
,
'
.DS_Store
'
,
'
__MACOSX
'
,
'
.git
'
];
excluded
.
push
(...
unusedAssets
);
return
excluded
.
every
(
e
=>
entry
.
indexOf
(
e
)
===
-
1
)
;
});
await
zip
.
writeZipPromise
(
exportPath
,
null
);
shell
.
showItemInFolder
(
exportPath
);
shell
.
showItemInFolder
(
exportPath
);
return
exportPath
;
return
exportPath
;
};
};
...
@@ -322,8 +330,8 @@ const getAllAssets = function (workdir) {
...
@@ -322,8 +330,8 @@ const getAllAssets = function (workdir) {
const
assetsName
=
[];
const
assetsName
=
[];
for
(
const
asset
of
assetPaths
)
{
for
(
const
asset
of
assetPaths
)
{
const
pathParts
=
asset
.
split
(
'
/
'
);
const
pathParts
=
asset
.
split
(
path
.
sep
);
const
prefix
=
pathParts
[
pathParts
.
length
-
2
]
===
'
icons
'
?
'
icons
/
'
:
''
;
const
prefix
=
pathParts
[
pathParts
.
length
-
2
]
===
'
icons
'
?
`
icons
${
path
.
sep
}
`
:
''
;
const
filename
=
prefix
+
pathParts
[
pathParts
.
length
-
1
];
const
filename
=
prefix
+
pathParts
[
pathParts
.
length
-
1
];
assetsName
.
push
(
filename
);
assetsName
.
push
(
filename
);
}
}
...
@@ -332,13 +340,13 @@ const getAllAssets = function (workdir) {
...
@@ -332,13 +340,13 @@ const getAllAssets = function (workdir) {
const
getUsedAssets
=
function
(
workdir
)
{
const
getUsedAssets
=
function
(
workdir
)
{
const
projectJSON
=
fs
.
readFileSync
(
path
.
join
(
workdir
,
'
project.json
'
),
'
utf8
'
);
const
projectJSON
=
fs
.
readFileSync
(
path
.
join
(
workdir
,
'
project.json
'
),
'
utf8
'
);
const
regex
=
/"assets
\/
([^
"
]
+
)
"/g
;
const
regex
=
/"assets
[\\/\\\\]
([^
"
]
+
)
"/g
;
const
matches
=
projectJSON
.
match
(
regex
);
const
matches
=
projectJSON
.
match
(
regex
);
if
(
!
matches
)
return
[];
if
(
!
matches
)
return
[];
return
matches
.
map
(
match
=>
{
return
matches
.
map
(
match
=>
{
return
match
.
replace
(
'
"
assets
/
'
,
''
)
return
match
.
replace
(
`
assets
${
path
.
sep
}
`
,
''
)
.
replace
(
'
"
'
,
''
)
.
replace
All
(
'
"
'
,
''
)
// To only keep the slash after icons
// To only keep the slash after icons
.
replace
(
/
\/
+/g
,
'
/
'
)
.
replace
(
/
\/
+/g
,
'
/
'
)
.
replace
(
/
\\
/g
,
''
);
.
replace
(
/
\\
/g
,
''
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment