Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JMXS03
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
JMXS03
Commits
6ae389b4
Commit
6ae389b4
authored
Nov 22, 2021
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改打包脚本的问题
parent
e09abde8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
36 deletions
+31
-36
publish.js
bin/publish.js
+31
-36
No files found.
bin/publish.js
View file @
6ae389b4
...
@@ -49,9 +49,7 @@ var copy=async function(src,dst){
...
@@ -49,9 +49,7 @@ var copy=async function(src,dst){
var
stats
=
await
fsp
.
stat
(
_src
);
var
stats
=
await
fsp
.
stat
(
_src
);
if
(
stats
.
isFile
()){
//如果是个文件则拷贝
if
(
stats
.
isFile
()){
//如果是个文件则拷贝
let
readable
=
fs
.
createReadStream
(
_src
);
//创建读取流
await
fsp
.
copyFile
(
_src
,
_dst
);
let
writable
=
fs
.
createWriteStream
(
_dst
);
//创建写入流
readable
.
pipe
(
writable
);
}
else
if
(
stats
.
isDirectory
()){
//是目录则 递归
}
else
if
(
stats
.
isDirectory
()){
//是目录则 递归
try
{
try
{
await
fsp
.
access
(
_dst
,
fs
.
constants
.
F_OK
);
await
fsp
.
access
(
_dst
,
fs
.
constants
.
F_OK
);
...
@@ -63,32 +61,8 @@ var copy=async function(src,dst){
...
@@ -63,32 +61,8 @@ var copy=async function(src,dst){
}
}
}
}
const
runSpawn
=
async
function
(){
var
zipDir
=
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
){
try
{
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/form
"
),
fs
.
constants
.
F_OK
);
}
catch
(
error
)
{
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/form
"
));
}
try
{
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/play
"
),
fs
.
constants
.
F_OK
);
}
catch
(
error
)
{
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/play
"
));
}
try
{
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/lib
"
),
fs
.
constants
.
F_OK
);
}
catch
(
error
)
{
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/lib
"
));
}
await
copy
(
path
.
resolve
(
__dirname
,
"
../form
"
),
path
.
resolve
(
__dirname
,
"
../dist/form
"
));
await
copy
(
path
.
resolve
(
__dirname
,
"
../play
"
),
path
.
resolve
(
__dirname
,
"
../dist/play
"
));
await
copy
(
path
.
resolve
(
__dirname
,
"
../lib
"
),
path
.
resolve
(
__dirname
,
"
../dist/lib
"
));
let
str
=
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
"
../dist/play/index.html
"
),{
encoding
:
'
utf8
'
});
str
=
str
.
replace
(
'
<base href="">
'
,
'
<base href="template-base-href">
'
);
fs
.
writeFileSync
(
path
.
resolve
(
__dirname
,
"
../dist/play/index.html
"
),
str
);
await
new
Promise
(
function
(
resolve
,
reject
){
let
pkg
=
require
(
"
../package.json
"
);
let
pkg
=
require
(
"
../package.json
"
);
//要压缩的目录
//要压缩的目录
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
);
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
);
...
@@ -119,12 +93,33 @@ const runSpawn = async function (){
...
@@ -119,12 +93,33 @@ const runSpawn = async function (){
});
});
}
}
// let projects = "";
const
runSpawn
=
async
function
(){
// if(process.argv.length<3){
try
{
// console.log("缺少参数");
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/form
"
),
fs
.
constants
.
F_OK
);
// return;
}
catch
(
error
)
{
// }
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/form
"
));
// projects = process.argv[2];
}
try
{
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/play
"
),
fs
.
constants
.
F_OK
);
}
catch
(
error
)
{
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/play
"
));
}
try
{
await
fsp
.
access
(
path
.
resolve
(
__dirname
,
"
../dist/lib
"
),
fs
.
constants
.
F_OK
);
}
catch
(
error
)
{
fs
.
mkdirSync
(
path
.
resolve
(
__dirname
,
"
../dist/lib
"
));
}
await
copy
(
path
.
resolve
(
__dirname
,
"
../form
"
),
path
.
resolve
(
__dirname
,
"
../dist/form
"
));
await
copy
(
path
.
resolve
(
__dirname
,
"
../play
"
),
path
.
resolve
(
__dirname
,
"
../dist/play
"
));
await
copy
(
path
.
resolve
(
__dirname
,
"
../lib
"
),
path
.
resolve
(
__dirname
,
"
../dist/lib
"
));
let
str
=
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
"
../dist/play/index.html
"
),{
encoding
:
'
utf8
'
});
str
=
str
.
replace
(
'
<base href="">
'
,
'
<base href="template-base-href">
'
);
fs
.
writeFileSync
(
path
.
resolve
(
__dirname
,
"
../dist/play/index.html
"
),
str
);
await
zipDir
();
}
let
exec
=
async
function
(){
let
exec
=
async
function
(){
//压缩模板
//压缩模板
...
...
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