Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PU22
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
PU22
Commits
359fda1c
Commit
359fda1c
authored
Sep 17, 2020
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: form打包生成文件名修改
parent
a32793c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
publish.js
form/bin/publish.js
+29
-28
No files found.
form/bin/publish.js
View file @
359fda1c
...
...
@@ -16,42 +16,42 @@ const compressing = require("compressing");
//Windows系统上'Windows_NT'
let
sysType
=
os
.
type
();
Date
.
prototype
.
Format
=
function
(
fmt
)
{
Date
.
prototype
.
Format
=
function
(
fmt
)
{
var
o
=
{
"
M+
"
:
this
.
getMonth
()
+
1
,
"
d+
"
:
this
.
getDate
(),
"
h+
"
:
this
.
getHours
(),
"
m+
"
:
this
.
getMinutes
(),
"
s+
"
:
this
.
getSeconds
(),
"
q+
"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
"
S
"
:
this
.
getMilliseconds
()
"
M+
"
:
this
.
getMonth
()
+
1
,
"
d+
"
:
this
.
getDate
(),
"
h+
"
:
this
.
getHours
(),
"
m+
"
:
this
.
getMinutes
(),
"
s+
"
:
this
.
getSeconds
(),
"
q+
"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
"
S
"
:
this
.
getMilliseconds
()
};
if
(
/
(
y+
)
/
.
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
for
(
var
k
in
o
)
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
fmt
))
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"
00
"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
return
fmt
;
}
function
clean
(
zipPath
){
if
(
fs
.
existsSync
(
zipPath
))
{
function
clean
(
zipPath
)
{
if
(
fs
.
existsSync
(
zipPath
))
{
fs
.
unlinkSync
(
zipPath
);
}
}
const
runSpawn
=
async
function
(){
const
runSpawn
=
async
function
()
{
await
new
Promise
(
function
(
resolve
,
reject
)
{
await
new
Promise
(
function
(
resolve
,
reject
)
{
let
pkg
=
require
(
"
../package.json
"
);
let
ls
;
if
(
sysType
===
"
Windows_NT
"
)
{
if
(
sysType
===
"
Windows_NT
"
)
{
//ng build --prod --build--optimizer --base-href /ng-one/
ls
=
spawn
(
"
cmd.exe
"
,
[
'
/c
'
,
'
ng
'
,
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]
);
}
else
{
ls
=
spawn
(
"
ng
"
,
[
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]
);
ls
=
spawn
(
"
cmd.exe
"
,
[
'
/c
'
,
'
ng
'
,
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]);
}
else
{
ls
=
spawn
(
"
ng
"
,
[
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]);
}
ls
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
...
...
@@ -66,28 +66,29 @@ const runSpawn = async function (){
ls
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
//要压缩的目录
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
,
pkg
.
name
);
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
,
pkg
.
name
);
//压缩包的存放目录
let
date
=
new
Date
();
let
zipname
=
pkg
.
name
+
"
_
"
+
date
.
Format
(
"
yyyyMMdd hh-mm-ss
"
);
let
zipdir
=
path
.
resolve
(
__dirname
,
"
../publish/
"
+
zipname
+
"
.zip
"
);
// let zipname = pkg.name+"_"+date.Format("yyyyMMdd hh-mm-ss");
let
zipname
=
'
form
'
;
let
zipdir
=
path
.
resolve
(
__dirname
,
"
../publish/
"
+
zipname
+
"
.zip
"
);
clean
(
zipdir
);
//删除原有的包
const
tarStream
=
new
compressing
.
zip
.
Stream
();
fs
.
readdir
(
zippath
,
function
(
err
,
files
)
{
if
(
err
)
{
fs
.
readdir
(
zippath
,
function
(
err
,
files
)
{
if
(
err
)
{
console
.
log
(
"
======文件打开异常======
"
);
console
.
log
(
err
);
reject
();
}
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
tarStream
.
addEntry
(
zippath
+
"
/
"
+
files
[
i
]);
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
tarStream
.
addEntry
(
zippath
+
"
/
"
+
files
[
i
]);
}
let
writeStream
=
fs
.
createWriteStream
(
zipdir
);
tarStream
.
pipe
(
writeStream
);
writeStream
.
on
(
'
close
'
,
()
=>
{
console
.
log
(
`模板
${
pkg
.
name
}
打包已完成!`
);
resolve
();
console
.
log
(
`模板
${
pkg
.
name
}
打包已完成!`
);
resolve
();
})
});
...
...
@@ -103,7 +104,7 @@ const runSpawn = async function (){
// }
// projects = process.argv[2];
let
exec
=
async
function
()
{
let
exec
=
async
function
()
{
//压缩模板
await
runSpawn
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment