2017-03-23 2 views
1

nehme an, wenn ich das ein Skript in package.json wieWie man einen Befehl von einem anderen in package.json anruft?

"scripts": { 
    "a1": "first command", 
    "a2": "second command", 
    "a3": "third command", 

    } 

und wenn ich Skript a1 haben und a2 im Skript a3 wie kann ich dies tun wollen laufen? Kann das möglich sein? Ich bin mit

Knoten Version: v6.9.4

npm Version: 4.3.0

Ich mag so etwas wie diese npm run im Skript

"scripts": { 
    "a1": "first command", 
    "a2": "second command", 
    "a3": "third command && a1 && a2", 

    } 

Antwort

4

Nutzung erreichen . Z.B.

"scripts": { 
    "a1": "first command", 
    "a2": "second command", 
    "a3": "third command && npm run a1 && npm run a2", 
} 

Lauf $ npm run a3 über die CLI die third command laufen (was immer das ist), gefolgt von a1, dann a2.

Wenn jedoch läuft $npm run a3 über die CLI nur laufen a1 von a2 dann folgte:

"scripts": { 
    "a1": "first command", 
    "a2": "second command", 
    "a3": "npm run a1 && npm run a2", 
} 
+0

thank you very much :) –

Verwandte Themen