コード例 #1
0
ファイル: NpmCommand.cs プロジェクト: yxbdali/nodejstools
        public virtual async Task <bool> ExecuteAsync()
        {
            OnCommandStarted();
            var redirector = new NpmCommandRedirector(this);

            try {
                GetPathToNpm();
            } catch (NpmNotFoundException) {
                redirector.WriteErrorLine(Resources.CouldNotFindNpm);
                return(false);
            }
            redirector.WriteLine(
                string.Format(CultureInfo.InvariantCulture, "===={0}====\r\n\r\n",
                              string.Format(CultureInfo.InvariantCulture, Resources.ExecutingCommand, Arguments)));

            var cancelled = false;

            try {
                await NpmHelpers.ExecuteNpmCommandAsync(
                    redirector,
                    GetPathToNpm(),
                    _fullPathToRootPackageDirectory,
                    new[] { Arguments },
                    _cancellation);
            } catch (OperationCanceledException) {
                cancelled = true;
            }
            OnCommandCompleted(Arguments, redirector.HasErrors, cancelled);
            return(!redirector.HasErrors);
        }
コード例 #2
0
        public virtual async Task<bool> ExecuteAsync() {
            OnCommandStarted();
            var redirector = new NpmCommandRedirector(this);

            try {
                GetPathToNpm();
            } catch (NpmNotFoundException) {
                redirector.WriteErrorLine(Resources.CouldNotFindNpm);
                return false;
            }
            redirector.WriteLine(
                string.Format("===={0}====\r\n\r\n",
                string.Format(Resources.ExecutingCommand, Arguments)));

            var cancelled = false;
            try {
                await NpmHelpers.ExecuteNpmCommandAsync(
                    redirector,
                    GetPathToNpm(),
                    _fullPathToRootPackageDirectory,
                    new[] { Arguments },
                    _cancellation);
            } catch (OperationCanceledException) {
                cancelled = true;
            }
            OnCommandCompleted(Arguments, redirector.HasErrors, cancelled);
            return !redirector.HasErrors;
        }