Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cocosTest
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
cocosTest
Commits
d407368e
Commit
d407368e
authored
Feb 28, 2020
by
liujiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove publish sub folder
parent
c7889aa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
publish.js
bin/publish.js
+14
-15
No files found.
bin/publish.js
View file @
d407368e
...
...
@@ -4,7 +4,7 @@
* 运行 npm run publish T_01,T_02,T_03,T_04 命令来分别打包 T_01,T_02,T_03,T_04 这四个模板,注意逗号要用英文的
* 运行 npm run publish all 命令来打包所有模板
*/
const
spawn
=
require
(
'
child_process
'
).
spawn
;
const
path
=
require
(
"
path
"
);
const
fs
=
require
(
"
fs
"
);
...
...
@@ -12,9 +12,9 @@ const os = require('os');
const
compressing
=
require
(
"
compressing
"
);
//Linux系统上'Linux'
//macOS 系统上'Darwin'
//macOS 系统上'Darwin'
//Windows系统上'Windows_NT'
let
sysType
=
os
.
type
();
let
sysType
=
os
.
type
();
Date
.
prototype
.
Format
=
function
(
fmt
)
{
var
o
=
{
...
...
@@ -44,9 +44,9 @@ const runSpawn = async function (){
await
new
Promise
(
function
(
resolve
,
reject
){
let
pkg
=
require
(
"
../package.json
"
);
let
pkg
=
require
(
"
../package.json
"
);
let
ls
;
let
ls
;
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/
'
]
);
...
...
@@ -57,7 +57,7 @@ const runSpawn = async function (){
ls
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`
${
data
}
`
);
});
ls
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stderr:
${
data
}
`
);
reject
();
...
...
@@ -66,13 +66,13 @@ const runSpawn = async function (){
ls
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
//要压缩的目录
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
);
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
"
);
clean
(
zipdir
);
//删除原有的包
const
tarStream
=
new
compressing
.
zip
.
Stream
();
fs
.
readdir
(
zippath
,
function
(
err
,
files
){
if
(
err
){
...
...
@@ -84,16 +84,16 @@ const runSpawn = async function (){
tarStream
.
addEntry
(
zippath
+
"
/
"
+
files
[
i
]);
}
let
writeStream
=
fs
.
createWriteStream
(
zipdir
);
tarStream
.
pipe
(
writeStream
);
tarStream
.
pipe
(
writeStream
);
writeStream
.
on
(
'
close
'
,
()
=>
{
console
.
log
(
`模板
${
pkg
.
name
}
打包已完成!`
);
resolve
();
})
});
});
});
});
});
}
// let projects = "";
...
...
@@ -101,7 +101,7 @@ const runSpawn = async function (){
// console.log("缺少参数");
// return;
// }
// projects = process.argv[2];
// projects = process.argv[2];
let
exec
=
async
function
(){
//压缩模板
...
...
@@ -110,6 +110,5 @@ let exec = async function(){
exec
();
\ No newline at end of file
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