Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bfc702

Browse files
committed
🚧 start on automated releases
1 parent0e0fe6c commit6bfc702

File tree

5 files changed

+8154
-0
lines changed

5 files changed

+8154
-0
lines changed

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "PeanutButter"]
55
path=PeanutButter
66
url=https://github.com/fluffynuts/PeanutButter
7+
[submodule "gulp-tasks"]
8+
path=gulp-tasks
9+
url=https://github.com/fluffynuts/gulp-tasks

‎gulp-tasks‎

Submodulegulp-tasks added at00d028f

‎gulpfile.js‎

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
/*
2+
Welcome new user!
3+
4+
To get started, copy this gulpfile.js to the root of your repo and run:
5+
`node gulpfile.js`
6+
You should be guided through the basic setup. More information in README.md. In
7+
particular, I highly recommend reading about how to use `local-tasks` to extend
8+
and / or override the default task-set.
9+
*/
10+
var
11+
fs=require("fs"),
12+
path=require("path"),
13+
gulpTasksFolder="gulp-tasks",// if you cloned elsewhere, you"ll need to modify this
14+
requireModule=global.requireModule=function(mod){
15+
varmodulePath=[".",gulpTasksFolder,"modules",mod].join("/");
16+
if(fs.existsSync(modulePath+".js")){
17+
returnrequire(modulePath);
18+
}else{
19+
returnrequire(mod);
20+
}
21+
};
22+
23+
24+
if(!fs.existsSync(gulpTasksFolder)){
25+
console.error("Either clone `gulp-tasks` to the `gulp-tasks` folder or modify this script to avoid sadness");
26+
process.exit(2);
27+
}
28+
29+
letautoWorking=null;
30+
functionpauseWhilstWorking(){
31+
const
32+
args=process.argv,
33+
lastTwo=args.slice(args.length-2),
34+
runningGulp=isGulpJs(lastTwo[0]),
35+
task=lastTwo[1];
36+
if(!runningGulp||!task){
37+
return;
38+
}
39+
autoWorking=true;
40+
try{
41+
constlocalGulp=require("gulp");
42+
localGulp.task(task,function(){
43+
console.log(`--- taking over your${task} task whilst we do some bootstrapping ---`);
44+
returnnewPromise(functionwatchWorker(resolve,reject){
45+
if(!autoWorking){
46+
returnresolve();
47+
}
48+
setTimeout(function(){
49+
watchWorker(resolve,reject);
50+
},500);
51+
});
52+
});
53+
}catch(e){
54+
/* suppress: may not have deps installed yet */
55+
}
56+
}
57+
functionisGulpJs(filePath){
58+
returnpath.basename(filePath)==="gulp.js";
59+
}
60+
61+
if(!fs.existsSync("package.json")){
62+
pauseWhilstWorking();
63+
console.log(
64+
"You need to set up a package.json first. I'll run `npm init` for you (:"
65+
);
66+
initializeNpm().then(()=>autoWorking=false);
67+
}elseif(mustInstallDeps()){
68+
pauseWhilstWorking();
69+
console.log(
70+
"Now we just need to install the dependencies required for gulp-tasks to run (:"
71+
);
72+
installGulpTaskDependencies().then(()=>{
73+
console.log("You're good to go with `gulp-tasks`. Try running `npm run gulp build`");
74+
autoWorking=false;
75+
});
76+
}else{
77+
bootstrapGulp();
78+
}
79+
80+
functionrequiredDeps(){
81+
varstarter=require([".",gulpTasksFolder,"start","package.json"].join("/"));
82+
returnObject.keys(starter.devDependencies);
83+
}
84+
85+
functionmustInstallDeps(){
86+
var
87+
package=require("./package.json"),
88+
devDeps=package.devDependencies||{},
89+
haveDeps=Object.keys(devDeps),
90+
needDeps=requiredDeps();
91+
returnneedDeps.reduce((acc,cur)=>{
92+
returnacc||haveDeps.indexOf(cur)==-1;
93+
},false);
94+
}
95+
96+
functioninitializeNpm(){
97+
varspawn=requireModule("spawn");
98+
varos=require("os");
99+
runNpmWith(["init"])
100+
.then(()=>{
101+
if(os.platform()==="win32"){
102+
spawn("cmd",["/c","node",process.argv[1]])
103+
}else{
104+
spawn("node",[process.argv[1]])
105+
}
106+
});
107+
}
108+
109+
functionaddMissingScript(package,name,script){
110+
package.scripts[name]=package.scripts[name]||script;
111+
}
112+
113+
functioninstallGulpTaskDependencies(){
114+
var
115+
findFirstMissing=function(){
116+
varargs=Array.from(arguments);
117+
returnargs.reduce((acc,cur)=>acc||(fs.existsSync(cur) ?acc :cur),undefined);
118+
},
119+
deps=requiredDeps(),
120+
package=require("./package.json"),
121+
buildTools=findFirstMissing("tools","build-tools",".tools",".build-tools"),
122+
prepend=`cross-env BUILD_TOOLS_FOLDER=${buildTools}`;
123+
124+
addMissingScript(package,"gulp",`${prepend} gulp`);
125+
addMissingScript(package,"test","run-s \"gulp test-dotnet\"");
126+
127+
fs.writeFileSync("package.json",JSON.stringify(package,null,4),{encoding:"utf8"});
128+
returnrunNpmWith(["install","--save-dev"].concat(deps));
129+
}
130+
131+
functiontestBin(cmds,pkg){
132+
if(!Array.isArray(cmds)){
133+
cmds=[cmds];
134+
}
135+
cmds.forEach(cmd=>{
136+
const
137+
expected=path.join("node_modules",".bin","cmd"),
138+
modPath=path.join("node_modules",pkg||cmds[0]);
139+
if(!fs.existsSync(expected)){
140+
if(fs.existsSync(modPath)){
141+
try{
142+
}catch(e){
143+
fs.renameSync(modPath,`${modPath}.b0rked.${newDate().getTime()}`);
144+
}
145+
}
146+
}
147+
});
148+
}
149+
150+
functionbootstrapGulp(){
151+
varimportNpmTasks=requireModule("import-npm-tasks");
152+
try{
153+
importNpmTasks();
154+
varrequireDir=require("require-dir");
155+
requireDir("gulp-tasks");
156+
["override-tasks","local-tasks"].forEach(function(dirname){
157+
if(fs.existsSync(dirname)){
158+
requireDir(dirname);
159+
}
160+
});
161+
}catch(e){
162+
if(shouldDump(e)){
163+
console.error(e);
164+
}else{
165+
if(!process.env.DEBUG){
166+
console.log(
167+
"Error occurred. For more info, set the DEBUG environment variable (eg set DEBUG=*)."
168+
);
169+
}
170+
}
171+
process.exit(1);
172+
}
173+
174+
functionshouldDump(e){
175+
returnprocess.env.ALWAYS_DUMP_GULP_ERRORS||probablyNotReportedByGulp(e);
176+
}
177+
178+
functionprobablyNotReportedByGulp(e){
179+
varmessage=(e||"").toString().toLowerCase();
180+
return["cannot find module","referenceerror","syntaxerror"].reduce(
181+
(acc,cur)=>{
182+
returnacc||message.indexOf(cur)>-1;
183+
},
184+
false
185+
);
186+
}
187+
}
188+
189+
functionrunNpmWith(args){
190+
varspawn=requireModule("spawn");
191+
varos=require("os");
192+
193+
testBin(["run-p","run-s"],"npm-run-all");
194+
testBin("cross-env");
195+
testBin("gulp");
196+
197+
returnos.platform()==="win32"
198+
?spawn("cmd",["/c","npm"].concat(args))
199+
:spawn("npm",args);
200+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp